Click here to Skip to main content
15,887,485 members
Home / Discussions / C#
   

C#

 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 3:20
drgsldr6927-Aug-12 3:20 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 3:29
professionalWes Aday27-Aug-12 3:29 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:29
drgsldr6927-Aug-12 5:29 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 5:34
professionalWes Aday27-Aug-12 5:34 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:36
drgsldr6927-Aug-12 5:36 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 5:42
professionalWes Aday27-Aug-12 5:42 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 5:45
drgsldr6927-Aug-12 5:45 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 6:02
professionalWes Aday27-Aug-12 6:02 
drgsldr69 wrote:
an example

First, your textbook should show you all of this. Second I cannot fix your code because it does not make any sense. I do not know what "dice" is or "BaseClass". But
C#
public void Character(int Str)
{
    string N;
    //N = base.Name();
    Console.Write("\n");
    Console.Write("Your Name is: {0} \n", N);
    //abilities.ShowAbilities(Str, Dex, Con, Int, Wis, Cha);
    ShowAbilities(Str);
}

public void ShowAbilities(int Str)
{
    Console.WriteLine("Strength:     {0}\n", Str);
    //Console.WriteLine("Dexterity:    {0}\n", Dex);
    //Console.WriteLine("Constitution: {0}\n", Con);
    //Console.WriteLine("Intelligence: {0}\n", Int);
    //Console.WriteLine("Wisdom:       {0}\n", Wis);
    //Console.WriteLine("Charisma:     {0}\n", Cha);
}

public void RollStr()
{
    //Abilities BaseClass = new Abilities();
    int Str;

    Str = dice.Roll5D6();
    Console.Write("Str: {0} \n", Str);
    //Reroll the dice
    char MyChoice;
    string MyInput;
    char ReRoll = Convert.ToChar("y");

    Console.Write("Would you like to reroll this score?");
    MyInput = Console.ReadLine();
    MyChoice = Convert.ToChar(MyInput);

    if (MyInput == Convert.ToString(ReRoll))
    {
        BaseClass.RollStr();
    }
    Character(Str);
}

should be enough to show you how to pass a variable from you RollStr method to your Character method and then to your ShowAbilites method. How you think you will do this in your real application is beyond me as you have not defined what your classes are or how they relate to each other.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012

GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 6:18
drgsldr6927-Aug-12 6:18 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 6:34
professionalWes Aday27-Aug-12 6:34 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 7:54
drgsldr6927-Aug-12 7:54 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 7:58
drgsldr6927-Aug-12 7:58 
GeneralRe: Trouble passing variables Pin
Wes Aday27-Aug-12 8:15
professionalWes Aday27-Aug-12 8:15 
GeneralRe: Trouble passing variables Pin
drgsldr6927-Aug-12 13:53
drgsldr6927-Aug-12 13:53 
AnswerRe: Trouble passing variables Pin
BillWoodruff26-Aug-12 15:23
professionalBillWoodruff26-Aug-12 15:23 
GeneralRe: Trouble passing variables Pin
drgsldr6926-Aug-12 15:44
drgsldr6926-Aug-12 15:44 
QuestionDatabase Connection on Deployment Pin
SHASHANK SAGAR26-Aug-12 8:36
SHASHANK SAGAR26-Aug-12 8:36 
AnswerRe: Database Connection on Deployment Pin
Eddy Vluggen26-Aug-12 8:49
professionalEddy Vluggen26-Aug-12 8:49 
AnswerRe: Database Connection on Deployment Pin
Vijay Selvaraj26-Aug-12 21:53
Vijay Selvaraj26-Aug-12 21:53 
GeneralRe: Database Connection on Deployment Pin
SHASHANK SAGAR27-Aug-12 3:07
SHASHANK SAGAR27-Aug-12 3:07 
AnswerRe: Database Connection on Deployment Pin
Shameel27-Aug-12 5:28
professionalShameel27-Aug-12 5:28 
QuestionWhere is my System.Drawing Pin
hosseinDolat25-Aug-12 22:55
hosseinDolat25-Aug-12 22:55 
AnswerRe: Where is my System.Drawing Pin
Richard MacCutchan25-Aug-12 23:02
mveRichard MacCutchan25-Aug-12 23:02 
AnswerRe: Where is my System.Drawing Pin
Eddy Vluggen25-Aug-12 23:32
professionalEddy Vluggen25-Aug-12 23:32 
GeneralRe: Where is my System.Drawing Pin
hosseinDolat26-Aug-12 0:04
hosseinDolat26-Aug-12 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.