Volatile Storage vs Non-Volatile Storage

Kristi Castro
Updated on 20-Jun-2020 16:43:19

3K+ Views

Volatile and Non-Volatile storage are the two forms of storage in any computer system.Volatile StorageThis is a type of computer memory that remains while there is power and the data is lost when power is switched off. A prime example of volatile memory is RAM. It is a type of primary storage. It allows the user to randomly access any part of the data regardless of its position in roughly the same time. This is not possible using other storage devices such as hard disks, CD’s etc. because they have physical constraints such rotation speeds, arm movements etc.There are mainly ... Read More

Sort List of Dictionaries by Values in C#

Arjun Thakur
Updated on 20-Jun-2020 16:42:53

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); }

What are Generic Collections in C#

Ankith Reddy
Updated on 20-Jun-2020 16:42:29

741 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

What are Generic Delegates in C#

George John
Updated on 20-Jun-2020 16:41:07

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

Key-Based I/O Collections in C#

Chandu yadav
Updated on 20-Jun-2020 16:38:04

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

What are Identifiers in C#

Arjun Thakur
Updated on 20-Jun-2020 16:37:21

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

What are Dynamic Data Types in C#

George John
Updated on 20-Jun-2020 16:35:50

602 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.

Overloaded Indexers in C#

Chandu yadav
Updated on 20-Jun-2020 16:35:18

802 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

Literals in C#

Arjun Thakur
Updated on 20-Jun-2020 16:32:18

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

What is String Title Case in C#

Ankith Reddy
Updated on 20-Jun-2020 16:31:55

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);

Advertisements