What is the best IDE for C# on MacOS?

George John
Updated on 20-Jun-2020 17:20:26

689 Views

On Windows, the best IDE to run C# programs is Visual Studio. On MacOS, the best IDE can be considered as Monodevelop.Monodevelop is an open source IDE that allows you to run C# on multiple platforms i.e. Windows, Linux and MacOS. Monodevelop is also known as Xamarin Studio.Monodevelop has a C# compiler to run C# programs. It can be used on Windows, macOS and Linux.For Mac, a special version of MonoDevelop was introduced and it was called Visual Studio for Mac. It has many of the features of what the same IDE provides for Windows like tool for and IntelliSense ... Read More

Try/catch/finally/throw keywords in C#

karthikeya Boyini
Updated on 20-Jun-2020 17:20:08

2K+ Views

Exception handling is based on the following keywords and its usage −try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed ... Read More

What is #define pre-processor directive in C#?

Samual Sam
Updated on 20-Jun-2020 17:19:12

275 Views

The #define pre-processor directive defines a sequence of characters, called symbol. It creates symbolic constants.#define lets you define a symbol such that, by using the symbol as the expression passed to the #if directive, the expression evaluates to true.Here is an example −Example#define ONE #undef TWO using System; namespace Demo {    class Program {       static void Main(string[] args) {          #if (ONE && TWO)          Console.WriteLine("Both are defined");          #elif (ONE && !TWO)          Console.WriteLine("ONE is defined and TWO is undefined");          #elif (!ONE && TWO)          Console.WriteLine("ONE is defined and TWO is undefined");          #else          Console.WriteLine("Both are undefined");          #endif       }    } }

What is the C# Equivalent of SQL Server DataTypes?

Chandu yadav
Updated on 20-Jun-2020 17:18:20

12K+ Views

The following table displays the C# equivalent of SQL Server datatypes −SQL Server data typeEquivalent C# data typevarbinaryByte[]binaryByte[]imageNonevarcharNonecharNonenvarcharString, Char[]ncharString, Char[]textNonentextNonerowversionByte[]bitBooleantinyintBytesmallintInt16intInt32bigintInt64smallmoneyDecimalmoneyDecimalnumericDecimaldecimalDecimalrealSinglefloatDoublesmalldatetimeDateTimedatetimeDateTimetableNonecursorNonetimestampNonexmlNone

What is the AddRange method in C# lists?

Chandu yadav
Updated on 20-Jun-2020 17:13:12

5K+ Views

AddRange method in lists adds an entire collection of elements. Let us see an example −Firstly, set a list in C# and add elements −List list = new List(); list.Add(100); list.Add(200); list.Add(300); list.Add(400);Now set an array of elements to be added to the list −// array of 4 elements int[] arr = new int[4]; arr[0] = 500; arr[1] = 600; arr[2] = 700; arr[3] = 800;Use the AddRange() method add the entire collection of elements in the list −list.AddRange(arr);Now let us see the complete code and display the list −using System; using System.Collections.Generic; class Demo {    static void ... Read More

What is the base class for all data types in C#.NET?

karthikeya Boyini
Updated on 20-Jun-2020 17:12:27

1K+ Views

Object is the base class for all data types in C#. The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System.Object class.When a value type is converted to object type, it is called boxing and on the other hand, when an object type is converted to a value type, it is called unboxing.The following is an example showing the usage of object data types −using System; using System.IO; namespace Demo {    class objectClass {       public int x = 56;   ... Read More

How to use LINQ in C#?

George John
Updated on 20-Jun-2020 17:11:39

446 Views

Language Integrated Query (LINQ) is a Microsoft .NET Framework component and the uniform query syntax in C#. It has a set of method names and extends the language with query expressions.For LINQ in C#, use −using System.Linq;Let us see an example. Here we have used the LINQ computational methods Count and Average to find the count of elements and average of those elements in C# −Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       int[] arr = { 87, 92, 45, 65, 34, 88 };       Console.WriteLine(arr.Average());       Console.WriteLine(arr.Count());    } }output68.5 6

How to use LINQ to sort a list in C#?

Samual Sam
Updated on 20-Jun-2020 17:11:01

542 Views

Use the LINQ orderby keyword to sort a list in C#.In the below example, we have set the orderby for the elements −var myLen = from element in myList orderby element.Length select element;Let us see an example −Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List myList = new List();       myList.Add("truck");       myList.Add("bus");       myList.Add("cab");       myList.Add("motorbike");       var myLen = from element in myList       orderby element.Length       select element; ... Read More

How to use NameValueCollection class in C#?

karthikeya Boyini
Updated on 20-Jun-2020 17:10:28

442 Views

The NameValueCollection sets more than one value for a single key. Now let us see how to use them in our C# program.Set the collection −static NameValueCollection GetCollection() {    NameValueCollection myCollection = new NameValueCollection();    myCollection.Add("Tim", "One");    myCollection.Add("John", "Two");    myCollection.Add("Jamie", "Three");    return myCollection; }Now with the GetCollection() method use the “AllKeys” method property to display all the keys −NameValueCollection myCollection = GetCollection(); foreach (string key in myCollection.AllKeys) {    Console.WriteLine(key); }

What are finalizers in C#?

Ankith Reddy
Updated on 20-Jun-2020 17:09:55

580 Views

Finalizers in C# are used to destruct instances of classes. With that, you can also use it to release resources.Here are some of the key points about Finalizers −Only one finalizer is allowed for a classYou cannot inherit or overload FinalizersA finalizer cannot have parametersFinalizers invoke automaticallyFinalizers in C# are declared like destructors. Let’s say the class name is Demo, therefore, the following would be our finalizer −~Demo() {    // }The finalizer declaration is prefixed with a tilde before the class name.

Advertisements