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
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
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());
superb. let me try it now :D
If you are satisfied please mark the tread as solved
Happy coding
can you tell me how to put OR in C#
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/library/6a71f45d(VS.80).aspx
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
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.
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)
class ConditionalOr
{
static bool Method1()
{
Console.WriteLine("Method1 called");
return true;
}
static bool Method2()
{
Console.WriteLine("Method2 called");
return false;
}
static void Main()
{
Console.WriteLine("regular OR:");
Console.WriteLine("result is {0}", Method1() | Method2());
Console.WriteLine("short-circuit OR:");
Console.WriteLine("result is {0}", Method1() || Method2());
}
}
/*
Output:
regular OR:
Method1 called
Method2 called
result is True
short-circuit OR:
Method1 called
result is True
*/
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.