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 2515 of 2650
3K+ Views
The fixed values are called literals. The constants refer to fixed values that the program may not alter during its execution.Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.Let us learn about integer, float, and string literals in C# −Integer LiteralsAn 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.Here are some example of Integer Literals −20 // ... Read More
801 Views
An indexer in C# allows an object to be indexed such as an array. When an indexer for a class is defined, this class behaves similar to a virtual array. You can then access the instance of this class using the array access operator ([ ]).Indexers can be overloaded. Indexers can also be declared with multiple parameters and each parameter may be a different type.The following is an example of overloaded indexers in C# −Example Live Demousing System; namespace IndexerApplication { class IndexedNames { private string[] namelist = new string[size]; static public int size ... Read More
600 Views
Store any type of value in the dynamic data type variable. Type checking for these types of variables takes place at run-time.The following is the syntax for declaring a dynamic type −dynamic = value;The following is an example −dynamic val1 = 100; dynamic val2 = 5; dynamic val3 = 20;The dynamic types are similar to object types except that type checking for object type variables takes place at compile time, whereas that for the dynamic type variables takes place at run time.
1K+ Views
An identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows −A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit.It must not contain any embedded space or symbol such as? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can ... Read More
219 Views
The key-based I/O Collections in C# is what we call a SortedList −SortedListThe SortedList class represents a collection of key-and-value pairs that are sorted by the keys and are accessible by key and by index. This is how both of them gets added in a SortedList −s.Add("Sub1", "Physics"); s.Add("Sub2", "Chemistry"); s.Add("Sub3", "Biology"); s.Add("Sub4", "Java");The following is an example displaying the keys and values in a SortedList −Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { SortedList s = new SortedList(); ... Read More
1K+ Views
Using generic delegates, you do not need to define the delegate statement. They are defined in the System namespace.You can define a generic delegate with type parameters. For example −delegate T myDelegete(T n);ExampleThe following is an example showing how to create generic delegates in C# −using System; using System.Collections.Generic; delegate T myDelegete(T n); namespace GenericDelegateAppl { class TestDelegate { static int num = 5; public static int AddNum(int p) { num += p; return num; } ... Read More
739 Views
Generic collections in C# include , , etc.ListList is a generic collection and the ArrayList is a non-generic collection.Let us see an example. Here, we have six elements in the list −Example Live Demousing System; using System.Collections.Generic; class Program { static void Main() { // Initializing collections List myList = new List() { "one", "two", "three", "four", "five", "six" }; Console.WriteLine(myList.Count); ... Read More
1K+ Views
Firstly, let us create a dictionary −var d = new Dictionary(5);Now add the key and value −// add key and value d.Add("car", 25); d.Add("bus", 28); d.Add("motorbike", 17);Use orderby to order by values −var val = from ele in d orderby ele.Value ascending select ele;We have set ascending above to sort the dictionary in ascending order. You can also use descending.Display the values in ascending order −foreach (KeyValuePair ele in val) { Console.WriteLine("{0} = {1}", ele.Key, ele.Value); }
936 Views
The System.IO namespace has various classes useful for performing various operations with files, such as creating and deleting files, reading from or writing to a file, closing a file etc.The following are the I/O classes in C# −Sr.No.I/O Class & Description1BinaryReaderReads primitive data from a binary stream.2BinaryWriterWrites primitive data in binary format.3BufferedStreamA temporary storage for a stream of bytes.4DirectoryHelps in manipulating a directory structure.5DirectoryInfoUsed for performing operations on directories.6DriveInfoProvides information for the drives.7FileHelps in manipulating files.8FileInfoUsed for performing operations on files.9FileStreamUsed to read from and write to any location in a file.10MemoryStreamUsed for random access to streamed data stored in ... Read More
1K+ Views
A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form.The following are some of the examples of floating point literals −9.23456 269485E-5FLet us now print the floating point literals −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { // float float a = 3.56f; Console.WriteLine(a); // float float b = 3.14159f; Console.WriteLine(b); } } }Output3.56 3.14159