Precious......
Next......
In this session we will learn Basic structure of a C# programme.
Next......
In this session we will learn Basic structure of a C# programme.
In part 1 we simply print a message by using "Console.writeline" keyword. But in this part we print a message which is printed by user. If user print "NetQube" then it return "Hello NetQube".
Two ways to write to console
a) Concatenation
b) Place holder syntax – Most preferred
Code samples used in the demo
We can Better understand by using another example
Precious......
Next......
a) Concatenation
b) Place holder syntax – Most preferred
Code samples used in the demo
using System;class Program{static void Main(){Console.WriteLine("enter your name");// Read the name from consolestring UserName = Console.ReadLine();// Concatenate name with hello word and printConsole.WriteLine("Hello " + UserName); // here UserName should be same because C# is a case sensitive//Placeholder syntax to print name with hello word//Console.WriteLine("Hello {0}", UserName);// here {0} is a place holder when we print user name then it substitute at {0} position}}
We can Better understand by using another example
using System;class Program{static void Main(){Console.WriteLine("enter your FirstName");string FirstName = Console.ReadLine();Console.WriteLine("enter your SecondName");string SecondName = Console.ReadLine();Console.WriteLine("Hello " + FirstName , SecondName);//Placeholder syntax to print name with hello word//Console.WriteLine("Hello {0} , {1}", FirstName , SecondName);}}
Precious......
Next......
No comments:
Post a Comment