Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Some Common Differences in C# Programming
WhatsApp
Sandeep Banerjee
10y
3.1
k
0
0
25
Blog
Difference between Concatenation and placeholder Syntax
using
System;
class
UserInteractive
{
public
static
void
Main()
{
string
name;
Console.WriteLine(
"What’s Your Name? "
);
Console.Write (
"Enter Your Name: "
);
name=Console.ReadLine();
Console.WriteLine(
"Hello! "
+name+” nice to meet you ”+name”.”);
//Concatenation
Console.WriteLine(“Hello! {0} nice to meet you {1}.”,name,name);
//placeholder
// placeholder are most preferable way.
}
}
Difference between Parse and TryPare
If the no. is in string format you have two option
parse and try parse
.
Parse method
throw an exception, if it cannot parse the value.
Whereas TryParse() return a bool indication whether it succeeded or failed.
Use parse() if you are sure the value use valid other wise use try parse.
using
System;
//use of parse
class
ParseTesting
{
public
static
void
Main()
{
string
strNumber=
"100"
;
int
i=
int
.Parse(strNumber);
Console.WriteLine(i);
}
}
using
System;
//use of try parse
class
TryparseTesting
{
public
static
void
Main()
{
string
strNumber=
"100TG"
;
int
Result;
bool
IsConversionSucessful=
int
.TryParse(strNumber,
out
Result);
if
(IsConversionSucessful)
{
Console.WriteLine(Result);
}
else
{
Console.WriteLine(
"Please Enter a valid number"
);
}
}
}
Difference between | and || or & and &&
If we use | or & it always check both the condition of statements whether it satisfies it or not it consume too much compiling time.
Other hand if we use || or && if left hand condition of statements satisfy them they don’t go to the right hand side it saves the compiling time.
TryPare
Parse
placeholder
Concatenation
People also reading
Membership not found