.NET QUEST for me is not just something, but everything that I have read, learned, searched, thought.. from my work & my experience. This website reflects my QUEST on .NET
Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts
April 6, 2014
base keyword in c#
The base keyword in C# is used from within the derived class to access the members / constructor of the base class. What i mean here is if the derived class wants to use a method of the base class that is overridden by another method or the derived class wants to specify which base class constructor should be used while creating instance of the derived class.
Example to come...
Thanks,
Hussain
January 2, 2014
Displaying Curly Braces { } in Console ouptut
Recently I was working on a sample console application for my tutorial and I happen to have a requirement, where in I had to display the curly braces as part of the formatted output.
Here’s the example ; Output of the console program should be: The number is -{124}
Solution:
As you are completely aware that curly braces is part of the c# keywords, for formatting object (e.g. numeric or string or class object etc.)
{
string x = “124″;
Console.WriteLine(“The number is -{x}”, x);
}
{
string x = “124″;
Console.WriteLine(“The number is -{x}”, x);
}
output : The number is -124
in the above example the output is still missing the curly braces, the solution to this is adding twice open and close {{ }} curly braces to get the desired output. Note is only for curely braces for all other special characters you need to use ‘\’
{
string x = “124″;
Console.WriteLine(“The number is -{{x}}”, x);
}
{
string x = “124″;
Console.WriteLine(“The number is -{{x}}”, x);
}
output : The number is -{124}
Thanks,
Hussain Patel
Subscribe to:
Posts (Atom)