any idea how to assign values to specific variables

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

any idea how to assign values to specific variables

 
0
  #1
Nov 15th, 2008
hi

im a noob in C#. just learning by my self. need to know how to assign values to variables. which we input

normally in C we use scanf ne. but in C#. how we gonna assign
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: any idea how to assign values to specific variables

 
0
  #2
Nov 15th, 2008
If you use the console to input data then use

Console.ReadLine() as follow

Say that you want to enter a string

Console.WriteLine("enter your name");
string Name = Console.ReadLine();

Now if you want enter variable other than string

Console.WriteLine("Enter your age");
int Age = Convert.ToInt32(Console.ReadLine());
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

Re: any idea how to assign values to specific variables

 
0
  #3
Nov 15th, 2008
superb. let me try it now
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 172
Reputation: Jugortha is an unknown quantity at this point 
Solved Threads: 16
Jugortha Jugortha is offline Offline
Junior Poster

Re: any idea how to assign values to specific variables

 
0
  #4
Nov 15th, 2008
If you are satisfied please mark the tread as solved

Happy coding
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 65
Reputation: lich has a little shameless behaviour in the past 
Solved Threads: 4
lich lich is offline Offline
Junior Poster in Training

Re: any idea how to assign values to specific variables

 
0
  #5
Nov 15th, 2008
can you tell me how to put OR in C#
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 276
Reputation: rapture has a spectacular aura about rapture has a spectacular aura about 
Solved Threads: 37
rapture rapture is offline Offline
Posting Whiz in Training

Re: any idea how to assign values to specific variables

 
0
  #6
Nov 15th, 2008
I think you should have marked the post solved for him as this is a different question bro

C# conditional OR operator is ||


http://msdn.microsoft.com/en-us/libr...5d(VS.80).aspx
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1
Reputation: siva_552 is an unknown quantity at this point 
Solved Threads: 1
siva_552 siva_552 is offline Offline
Newbie Poster

Re: any idea how to assign values to specific variables

 
0
  #7
Nov 15th, 2008
Originally Posted by lich View Post
hi

im a noob in C#. just learning by my self. need to know how to assign values to variables. which we input

normally in C we use scanf ne. but in C#. how we gonna assign
mr.noob i know one way just try it
normally in c we r use scanf()

in C#.net
console.write() write to console and stop
console.writeln() going to next line
console.ReadLine() for user input
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 249
Reputation: Antenka has a spectacular aura about Antenka has a spectacular aura about Antenka has a spectacular aura about 
Solved Threads: 65
Antenka's Avatar
Antenka Antenka is offline Offline
Posting Whiz in Training

Re: any idea how to assign values to specific variables

 
0
  #8
Nov 15th, 2008
Beforehand, sorry for my english...
The || - is short version of |.
I.e. if you have simple condition like this:
(a||b) then, there is no difference, what operator to use. In case with complex condition:
((a==b)||(c==d)||(e==f)) will be difference. The || operator will be checking the conditions, untill it find TRUE. If it happened on (a==b), the other conditions will not be checked. If you are choose the | operator, then all conditions will be checked necessarily.
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,908
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 274
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: any idea how to assign values to specific variables

 
1
  #9
Nov 16th, 2008
Originally Posted by Antenka
The || - is short version of |.
That is not quite true, but I realize at first it was fuzzy for myself also.

|| is a conditional OR, it works with booleans : Abool || Bbool, if Abool is true it won't look at Bbool.

| is a bitwise OR it works with booleans and with integral types, it will always perform a bitwise OR on both sides.

Look at this code snippet I found on MSDN(search for C# operators)
  1. class ConditionalOr
  2. {
  3. static bool Method1()
  4. {
  5. Console.WriteLine("Method1 called");
  6. return true;
  7. }
  8.  
  9. static bool Method2()
  10. {
  11. Console.WriteLine("Method2 called");
  12. return false;
  13. }
  14.  
  15. static void Main()
  16. {
  17. Console.WriteLine("regular OR:");
  18. Console.WriteLine("result is {0}", Method1() | Method2());
  19. Console.WriteLine("short-circuit OR:");
  20. Console.WriteLine("result is {0}", Method1() || Method2());
  21. }
  22. }
  23. /*
  24. Output:
  25. regular OR:
  26. Method1 called
  27. Method2 called
  28. result is True
  29. short-circuit OR:
  30. Method1 called
  31. result is True
  32. */
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC