Found 33676 Articles for Programming

C# Console.WindowTop Property

Ankith Reddy
Updated on 23-Jun-2020 08:20:56

196 Views

The WindowsTop property is used to gets or set the top position of the console window area relative to the screen buffer.Declare an integer variable to get the top position.int top;Now, use the Console.WindowTop property.top = Console.WindowTop;Let us see the complete example.Example Live Demousing System; class Demo {    static void Main() {       int top;       top = Console.WindowTop;       Console.WriteLine("Top position of the Console window = "+top);    } }OutputTop position of the Console window = 0

C# Console BufferWidth Property

karthikeya Boyini
Updated on 23-Jun-2020 08:21:16

205 Views

Use the BufferWidth gets or sets the width of the buffer area.Use the property like this −Console.BufferWidthLet us see the complete example.Example Live Demousing System; class Demo {    static void Main() {       Console.WriteLine("Buffer width (columns) = "+Console.BufferWidth);    } }OutputBuffer width (columns) = 0

C# Linq Reverse Method

Arjun Thakur
Updated on 23-Jun-2020 08:21:46

946 Views

Reverse the elements in an array, using the Reverse method.Here is our character array.char[] ch = { 't', 'i', 'm', 'e' };Now use the Reverse() method with AsQueryable() method to get the reverse.ch.AsQueryable().Reverse();Let us see the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       char[] ch = { 't', 'i', 'm', 'e' };       Console.Write("String = ");       foreach(char arr in ch) {          Console.Write(arr);       }       IQueryable res = ch.AsQueryable().Reverse();       Console.Write("Reversed String = ");       foreach (char c in res) {          Console.Write(c);       }    } }OutputString = time Reversed String = emit

Full Date Long Time ("F") Format Specifier in C#

Samual Sam
Updated on 23-Jun-2020 08:22:05

220 Views

The Full Date Long Time standard format specifier’s custom date and time format string is defined by the current DateTimeFormatInfo.FullDateTimePattern property.The custom format string is −dddd, dd MMMM yyyy HH:mm:ssExample Live Demousing System; using System.Globalization; class Demo {    static void Main() {       DateTime myDate = new DateTime(2018, 8, 13, 9, 15, 0);       Console.WriteLine(myDate.ToString("F", CultureInfo.CreateSpecificCulture("en-US")));    } }OutputMonday, August 13, 2018 9:15:00 AM

Implicit conversion from 16-bit unsigned integer (ushort) to Decimal in C#

Chandu yadav
Updated on 23-Jun-2020 08:22:29

452 Views

UShort represents a 16-bit unsigned integer.To implicitly convert of a 16-bit unsigned integer to a decimal, firstly set a ushort value.ushort val = 193;To convert ushort to decimal, assign the value.decimal dec; dec = val;Let us see an example.Exampleusing System; public class Demo {    public static void Main() {       ushort val = 2567;       decimal dec;       Console.WriteLine("Implicit conversion from 16-bit unsigned integer to Decimal");       dec = val;       Console.WriteLine("Decimal = "+dec);    } }

C# Orderby Descending

karthikeya Boyini
Updated on 23-Jun-2020 08:23:07

380 Views

Use Orderby descending in C# to sort elements in descending order.The following is our list −IList emp = new List() { new Employee() { EmployeeRank = 3, EmpName = "Tom", EmpMarks = 90 } , new Employee() { EmployeeRank = 4, EmpName = "Katie", EmpMarks = 95 } };Now to sort the list according to Student name, use Orderby. The default is ascending, therefore for descending order, use descending.var res = from str in emp orderby str.EmpName descending select str;Here is the complete code.Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() { ... Read More

Represent Int32 as a Octal String in C#

George John
Updated on 23-Jun-2020 08:23:40

1K+ Views

To represent Int32 as a Octal string in C#, use the ToString() method and set the base as the ToString() method’s second parameter i.e. 8 for Octal.Int32 represents a 32-bit signed integer.Firstly, set an Int32 variable.int val = 99;Now, convert it to octal string by including 8 as the second parameter.Convert.ToString(val, 8)Example Live Demousing System; class Demo {    static void Main() {       int val = 99;       Console.WriteLine("Integer: "+val);       Console.Write("Octal String: "+Convert.ToString(val, 8));    } }OutputInteger: 99 Octal String: 143

Sort list elements in descending order in C#

Samual Sam
Updated on 23-Jun-2020 08:24:22

1K+ Views

The following is our list with elements −IList emp = new List() {    new Employee() { EmployeeRank = 4, EmpName = "Amit", EmpMarks = 90 } ,    new Employee() { EmployeeRank = 05, EmpName = "Raman", EmpMarks = 95 } };Now use orderby and descending to sort elements in descending order.var res = from str in emp orderby str.EmpName descending select str;Example Live Demousing System; using System.Linq; using System.Collections.Generic; public class Demo {    public static void Main() {       IList emp = new List() {          new Employee() { EmployeeRank = 4, EmpName ... Read More

C# Queryable Min Method

Ankith Reddy
Updated on 23-Jun-2020 08:14:53

152 Views

Get the minimum value from a sequence using the Min() method in C#.The following is our list.List list = new List { 1, 2, 3, 4, 5, 6 };Now, use Queryable Min() method to get minimum element.list.AsQueryable().Min();Exampleusing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List list = new List { 1, 2, 3, 4, 5, 6 };       foreach(long ele in list) {          Console.WriteLine(ele);       }       // getting lowest element       long min_num = list.AsQueryable().Min();       Console.WriteLine("Smallest number = {0}", mix_num);    } }

C# Queryable Max Method

karthikeya Boyini
Updated on 23-Jun-2020 08:15:18

210 Views

Get the maximum value from a sequence using the Max() method.Let’s say the following is our list.List list = new List { 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 };Use the Max() method to get the largest element.list.AsQueryable().Max();Example Live Demousing System; using System.Collections.Generic; using System.Linq; class Demo {    static void Main() {       List list = new List { 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 };       foreach(long ele in list)       Console.WriteLine(ele);       // getting largest element       long max_num = list.AsQueryable().Max();       Console.WriteLine("Largest number = {0}", max_num);    } }Output200 400 600 800 1000 1200 1400 1600 1800 2000 Largest number = 2000

Advertisements