Re: C # question

Hi: As far as I know you do not have global variables in CSharp. You would define a class to hold your global variables. If you define it as static, I think that is what it is called, you will not have to instantiate the class whenever you want to use the variable.

Rick USA
----- Original Message ----- From: "Celia Rodriguez" <celia-rodriguez@xxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, November 25, 2009 7:15 PM
Subject: C # question

Hi everyone,,
First of all, thanks to all who responded to my last question.

Here is one more question, if you all don't mind.

If I have a simple program with no classes, but one or more methods,. and I declared a decimal variable in one of the methods. how can I reference this
variable in more then one method??

Would I  define the variable as public  or global?  I tried both with no
result maybe I am putting it in the wrong place?

Thank Yu,
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Varun Khosla
Sent: Monday, November 23, 2009 10:18 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: Hi Rick

Hi Celia,
You cannot do it directly with numeric datatypes; however, converting
one to string can do the same, as:

int num = 281;
int hundredPart = int.Parse(num.ToString()
.ToString()); // I've broken the statement to make it easy to follow.

First, you convert the number into string. Then, you access the first
character (number in this case) using the character array notation (a
string is simply a sequence of characters). And lastly, you simply
convert the first character (2) back to int using the Parse method. I
have used the ToString method in the last step (to convert the
character into string) because, the int.Parse method requires an
argument of type  string (and not a char type) to operate on.



On 11/23/09, Celia Rodriguez <celia-rodriguez@xxxxxxxxxxxxx> wrote:
In C# is there a way to reference a single digit out of a x number?

For example:

IfI have a number 281, and I only want to reference the number 2, how can
do this

Thank you for any help.


View the list's information and change your settings at

View the list's information and change your settings at

View the list's information and change your settings at

Other related posts: