Found 2628 Articles for Csharp

Log functions in C#

Samual Sam
Updated on 21-Jun-2020 12:31:31

1K+ Views

With C#, you can easily work with Logarithms. It has the following methods for Log as well as Log base 10.Sr.NoMethod & Description1Log(Double)Returns the natural (base e) logarithm of a specified number.2LogDouble)(Double,Returns the logarithm of a specified number in a specified base.3Log10(Double)Returns the base 10 logarithm of a specified number.Let us see an example to work with Log functions in C# −Exampleusing System; class Demo {    static void Main() {       double val1 = Math.Log(1);       Console.WriteLine(val1);       double val2 = Math.Log10(1000);       Console.WriteLine(val2);    } }

List down a list of the escape characters in C#

Arjun Thakur
Updated on 21-Jun-2020 12:34:14

755 Views

The following is the list of escape characters in C# −Escape characterDescriptionPattern\aMatches a bell character, \u0007.\a\bIn a character class, matches a backspace, \u0008.[\b]{3, }\tMatches a tab, \u0009.(\w+)\t\rMatches a carriage return, \u000D. (\r is not equivalent to the newline character, .)\r(\w+)\vMatches a vertical tab, \u000B.[\v]{2, }\fMatches a form feed, \u000C.[\f]{2, }Matches a new line, \u000A.\r(\w+)\eMatches an escape, \u001B.\ennUses octal representation to specify a character (nnnconsists of up to three digits).\w\040\w\x nnUses hexadecimal representation to specify a character (nn consists of exactly two digits).\w\x20\w\c X\c xMatches the ASCII control character that is specified by X or x, where X or x is ... Read More

Math class methods in C#

karthikeya Boyini
Updated on 21-Jun-2020 12:33:38

339 Views

The System.Math class in C# provides methods are properties to perform mathematical operations, trigonometric, logarithmic calculations, etc.Some of its methods include −Sr.NoMethod & Description1Abs(Decimal)Returns the absolute value of a Decimal number.2Abs(Double)Returns the absolute value of a double-precision floating-point number.3Abs(Int16)Returns the absolute value of a 16-bit signed integer.4Abs(Int32)Returns the absolute value of a 32-bit signed integer.5Abs(Int64)Returns the absolute value of a 64-bit signed integer.6Abs(SByte)Returns the absolute value of an 8-bit signed integer.7Abs(Single)Returns the absolute value of a single-precision floating-point number.8Acos(Double)Returns the angle whose cosine is the specified number.9Asin(Double)Returns the angle whose sine is the specified number.10Atan(Double)Returns the angle whose tangent is ... Read More

What are types in C#?

Ankith Reddy
Updated on 21-Jun-2020 12:36:45

96 Views

The types in C# include the following −Value TypesValue type variables can be assigned a value directly. They are derived from the class System.ValueType.The value types directly contain data. Some examples are int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively. When you declare an int type, the system allocates memory to store the value.Reference TypesThe reference types do not contain the actual data stored in a variable, but they contain a reference to the variables.Pointer TypesPointer type variables store the memory address of another type. Pointers in C# have the same capabilities as the pointers ... Read More

What are two-dimensional arrays in C#?

George John
Updated on 21-Jun-2020 12:20:25

227 Views

A 2-dimensional array is a list of one-dimensional arrays.Two-dimensional arrays may be initialized by specifying bracketed values for each row.int [,] a = new int [2,2] {    {0, 1} ,    {4, 5} };The following is an example showing how to work with two-dimensional arrays in C# −using System; namespace ArrayApplication {    class MyArray {       static void Main(string[] args) {          /* an array with 3 rows and 2 columns*/          int[,] a = new int[3, 2] {{0,0}, {1,2}, {2,4} };          int i, j;          /* output each array element's value */          for (i = 0; i < 3; i++) {             for (j = 0; j < 2; j++) {                Console.WriteLine("a[{0},{1}] = {2}", i, j, a[i,j]);             }          }          Console.ReadKey();       }    } }

What are tokens in C#?

Samual Sam
Updated on 21-Jun-2020 12:17:27

2K+ Views

Token is the smallest element of a program. Let us learn about identifiers and keywords in C# that are tokens −KeywordsKeywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. However, if you want to use these keywords as identifiers, you may prefix the keyword with the @ character.The following are some of the reserved keywords in C# −abstractAsBaseboolBreakbytecasecatchcharcheckedclassConstcontinuedecimaldefaultdelegateDodoubleElseenumeventexplicitexternFalsefinallyFixedfloatforforeachgotoIfimplicitInin (generic modifier)intinterfaceinternalIslockLongnamespacenewnullobjectoperatoroutout (generic modifier)overrideparamsIdentifiersAn 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 ... Read More

What are the rules for naming classes in C#?

karthikeya Boyini
Updated on 21-Jun-2020 12:28:25

369 Views

A class definition starts with the keyword class followed by the class name; and the class body enclosed by a pair of curly braces.The following is the syntax − class class_name {    // member variables     variable1;     variable2;    ...     variableN;    // member methods     method1(parameter_list) {       // method body    }     method2(parameter_list) {    // method body    }    ...     methodN(parameter_list) {       // method body    } }The following are the conventions ... Read More

What are the prerequisites for learning C#?

Arjun Thakur
Updated on 21-Jun-2020 12:27:50

403 Views

To start learning C#, firstly you should have computer knowledge. With that, if you have a prior learning experience in C or C#, then it would be great.To start with C#, first install Visual Studio. The current version is Visual Studio 2017.If you want to avoid the hassles of installing a bulky Visual Studio IDE, then you can begin with Online Compilers. The top online compilers to run C# programs are −Coding groundDotNetFiddleBoth of the above are intelligent compilers. Just go there, type the C# code and run it. That’s it!

What are the interfaces implemented by Array class in C#?

Samual Sam
Updated on 21-Jun-2020 12:05:51

804 Views

System.Array implements interfaces, like ICloneable, IList, ICollection, and IEnumerable, etc. The ICloneable interface creates a copy of the existing object i.e a clone.Let us see learn about the ICloneable interface. It only has a Clone() methods because it creates a new object that is a copy of the current instance.The following is an example showing how to perform cloning using ICloneable interface −Exampleusing System; class Car : ICloneable {    int width;    public Car(int width) {       this.width = width;    }    public object Clone() {       return new Car(this.width);   ... Read More

What are the hidden features of C#?

Chandu yadav
Updated on 21-Jun-2020 12:06:09

285 Views

The following are the hidden or lesser known useful features of C# −Lambda ExpressionsA lambda expression in C# describes a pattern. It has the token => in an expression context. This is called goes to operator and used when a lambda expression is declared.NullablesC# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values. The following is the syntax − ? = null;Null Coalescing OperatorThe null coalescing operator is used with the nullable value types and reference types. It is used for converting an operand to the ... Read More

Advertisements