TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mazetar
NA
6
11.9k
Getting a specific nummber from an Array based on variable?
Apr 1 2011 11:48 AM
I have an Array of nummbers like this:
int[] baseSavingThrows = {2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12};
and I have a:
int level;
what I want to do is to be able to get a # from the array based on the level.
I tried using 2d arrays as well as single arrays but I havent been able to figure out how to do this.
I know I can use
Console.WriteLine("Your saving Throw is: {0}", baseSavingThrows);
to display the line: Your saving Throw is: 2
but I can't figure out a way to modify it so it changes with the level variable.
I plan to later use the baseSavingThrows to get the base number and then use it in my calculations, to calculate inn different modifiers and get a totalSaveBonus and then compare that number against another number and then do an action based on that.
The problem is that I can't find a way to extract the correct nummber based on the level variable, so I know I'm doing somthing really wrong and I'm wondering if anyone here has any pointers?
Reply
Answers (
1
)
Re-bind datagrid when window is closed
How to split the line by line