Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 2514 of 2650
1K+ Views
Like any other object-oriented language, C# also has object and classes. Objects are real-world entities and instance of a class. Access the members of the class using an object.To access the class members, you need to use the dot (.) operator after the object name. The dot operator links the name of an object with the name of a member, for example, Box b1 = new Box();Above you can see Box1 is our object. We will use it to access the members −b1.height = 7.0;You can also use it to call member functions −b1.getVolume();The following is an example showing how ... Read More
1K+ Views
Mixed arrays are a combination of multi-dimension arrays and jagged arrays.Note − The mixed arrays type is obsolete now since .NET 4.0 update removed it.Let us see how you can declare a mixed array −var x = new object[] {89, 45, "jacob", 9.8}We can also set them as −var x = new object[] {87, 33, "tim", 6.7, new List() {"football", "tennis", "squash", “cricket”} }Since, mixed arrays are obslete now. For the same work, use the List collection. Here, we have set int and string in the list −Tuple tuple = new Tuple(60, "John");The same example is displayed below:using System; using ... Read More
418 Views
C# has the following file operations −Create, open, read and write a file.Append, Delete, etc.The FileStream class in the System.IO namespace helps in reading from, writing to and closing files. This class derives from the abstract class Stream.You need to create a FileStream object to create a new file or open an existing file. The syntax for creating a FileStream object is as follows −FileStream = new FileStream( , , , );Here, the file operations are also included as shown below −The FileMode enumerator defines various methods for opening files. The members of the FileMode enumerator are −Append − It ... Read More
676 Views
An integer literal can be a decimal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, and there is no prefix id for decimal. It can also have a suffix that is a combination of U and L, for unsigned and long, respectively.Here are some of the examples of integer literals −200 // int 90u// unsigned intLet’s use the above literal while declaring and initializing a variable −// int int a =200;We will now print the values −Example Live Demousing System; namespace Demo { class Program { static ... Read More
18K+ Views
Use the ReadLine() method to read input from the console in C#. This method receives the input as string, therefore you need to convert it.For example −Let us see how to get user input from user and convert it to integer.Firstly, read user input −string val; Console.Write("Enter integer: "); val = Console.ReadLine();Now convert it to integer −int a = Convert.ToInt32(val); Console.WriteLine("Your input: {0}", a);Let us see this in an example. The input is added using command line argument−Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { string val; Console.Write("Enter ... Read More
1K+ Views
The following are the escape characters in C# and the display column suggests how to use and print them in C# −Escape CharacterDescriptionPatternDisplay\aMatches a bell character, \u0007.\a"\u0007" in "Warning!" + '\u0007'\bIn a character class, matches a backspace, \u0008.[\b]{3, }"\b\b\b\b" in "\b\b\b\b"\tMatches a tab, \u0009.(\w+)\t"Name\t", "Addr\t" in "Name\tAddr\t"\rMatches a carriage return, \u000D. (\r is not equivalent to the newline character, .)\r(\w+)"\rHello" in "\r\HelloWorld."\vMatches a vertical tab, \u000B.[\v]{2, }"\v\v\v" in "\v\v\v"\fMatches a form feed, \u000C.[\f]{2, }"\f\f\f" in "\f\f\f"Matches a new line, \u000A.\r(\w+)"\rHello" in "\r\HelloWorld."\eMatches an escape, \u001B.\e"\x001B" in "\x001B"nnUses octal representation to specify a character (nnn consists of up to three digits).\w\040\w"a ... Read More
2K+ Views
Firstly, set a character−char ch = 'K';Now simply increment it like this −ch++;If you will print the character now, it would be the next character as shown in the following example −Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { char ch = 'K'; Console.WriteLine("Initial character:"+ch); // increment character ch++; Console.WriteLine("New character:"+ch); } }OutputInitial character:K New character:L
1K+ Views
HashtableA hash table is used when you need to access elements by using key, and you can identify a useful key value. Each item in the hash table has a key/value pair. The key is used to access the items in the collection.The members in a Hashtable are thread safe. It returns null if we try to find a key that does not exist. Hashtable is not a generic type.The Hashtable collection is slower than dictionary because it requires boxing and unboxing.To declare a Hashtable −Hashtable ht = new Hashtable();DictionaryDictionary is a collection of keys and values in C#. Dictionary ... Read More
315 Views
A lambda expression in C# describes a pattern. It has the token => in an expression context. This is read as “goes to” operator and used when a lambda expression is declared.The following is an example showing how to use lambda expressions in C# −Example Live Demousing System; using System.Collections.Generic; class Demo { static void Main() { List list = new List() { 21, 17, 40, 11, 9 }; int res = list.FindIndex(x => x % 2 == 0); Console.WriteLine("Index: "+res); } }OutputIndex: 2Above, we saw the usage of ... Read More
2K+ Views
The ToTitleCase method is used to capitalize the first letter in a word. Title case itself means to capitalize the first letter of each major word.Let us see an example to get the title case −Example Live Demousing System; using System.Globalization; class Demo { static void Main() { string str = "jack sparrow"; string res = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str); Console.WriteLine(res); } }OutputJack SparrowAbove, we have set the input string to the ToTitleCase() method. The CultureInfo.TextInfo property is used to provide the culture-specific casing information for strings −CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str);