Found 33676 Articles for Programming

Mathematical Functions in C#

karthikeya Boyini
Updated on 21-Jun-2020 12:41:40

2K+ 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

Logical Operators on String in C#

George John
Updated on 21-Jun-2020 12:40:48

1K+ Views

The following are the logical operators that you can use on Strings in C#.OperatorDescriptionExample&&Called Logical AND operator. If both the operands are non zero then condition becomes true.(A && B) is false.||Called Logical OR Operator. If any of the two operands is non zero then condition becomes true.(A || B) is true.!Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false.!(A && B) is true.Let us see an example showing how to use logical AND operator on strings −Example Live Demousing System; using System.Collections.Generic; using System.Linq; ... Read More

Listing out directories and files using C#

karthikeya Boyini
Updated on 21-Jun-2020 12:41:57

522 Views

The Directory class in C# has many methods to perform operations on directories and sub-directories −Sr.NoMethod & Description1CreateDirectory(String)Creates all directories and subdirectories in the specified path unless they already exist.2CreateDirectoryDirectorySecurity(String)Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.3Delete(String)Deletes an empty directory from a specified path.4DeleteBoolean(String)Deletes the specified directory and, if indicated, any subdirectories and files in the directory.5EnumerateDirectories(String)Returns an enumerable collection of directory names in a specified path.6EnumerateDirectories(String, String)Returns an enumerable collection of directory names that match a search pattern in a specified path.To get the directory names, use the EnumerateDirectories method. ... Read More

Log functions in C#

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

2K+ 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

1K+ 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

562 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

191 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

385 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

3K+ 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

483 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

Advertisements