Re: C # question

  • From: Tyler Littlefield <tyler@xxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Wed, 25 Nov 2009 18:42:36 -0700

Hello,
the public keyword marks the scope of the variable to the public scope in 
whatever class it's in. There is no "global" keyword, as far as I know. I 
recommend using a class (You have to anyway for the main function I believe), 
or passing the variable as an argument to the functions that need it, either 
byref or byval.
HTH,

On Nov 25, 2009, at 5:15 PM, Celia Rodriguez wrote:

>               
> 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,
> Celia
> 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()
> [0]
> .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.
> 
> HTH
> 
> Varun
> 
> 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
> I
>> do this
>> 
>> 
>> 
>> Thank you for any help.
>> 
>> celia
>> 
>> 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind
> 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: