Ankith Reddy has Published 996 Articles

Convert.ToInt64 Method in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:46:10

627 Views

Convert a specified value to a 64-bit signed integer using Convert.ToInt64 Method.Let us take a double value.double doubleNum = 193.834;Now, convert it to Int64 i.e. long.long res; res = Convert.ToInt32(doubleNum);Example Live Demousing System; public class Demo {    public static void Main() {       double doubleNum = 193.834;   ... Read More

Implicit conversion from Char to Decimal in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:42:22

2K+ Views

To implicitly convert char to a Decimal, firstly set a char.char c = 'p';To convert char to decimal, assign the value.decimal dec; dec = c;Let us see the above example.Example Live Demousing System; public class Demo {    public static void Main() {       char c = 'p';   ... Read More

C# into keyword

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:40:16

133 Views

Set query in a select clause using the into operator.The following is our list with Employee details −IList employee = new List() {    new Employee() { EmpID = 1, EmpName = "Tom", EmpMarks = 90, Rank = 8} ,    new Employee() { EmpID = 2, EmpName = "Anne", ... Read More

C# Program to get current day of week

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:31:14

16K+ Views

Use DateTime. DayOfWeek property to display the current day of week.DayOfWeek wk = DateTime.Today.DayOfWeek;Now, displaying “wk” would give you the current day of the week.Let us see the complete code to get the current day of week.Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() ... Read More

C# TimeSpan Max value

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:27:05

1K+ Views

Timespan shows the length of time.To get the maximum value of TimeSpan, use the following property.TimeSpan.MaxValueExample Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       Console.WriteLine(TimeSpan.MaxValue);    } }Output10675199.02:48:05.4775807

C# Console.WindowLeft Property

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:21:53

236 Views

The WindowsLeft property gets or sets the leftmost position of the console window area relative to the screen buffer.Declare an integer variable to get the leftmost position.int left;Now, use the Console.WindowLeft property.left = Console.WindowLeftLet us see the complete example.Example Live Demousing System; class Demo {    static void Main() {   ... Read More

Full Date Short Time ("f") Format Specifier in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:19:26

195 Views

The Full Date Short Time standard format specifier represents a combination of the long date ("D") and short time ("t") patterns.UseDateTime to set the date.DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);Now, use the (“f”) format specifier like this −myDate.ToString("f", CultureInfo.CreateSpecificCulture("en-US"))The following is an example −Example Live Demousing System; ... Read More

Delete a file in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:12:15

926 Views

Use File.Delete method to delete a file.Firstly, set the path of the file you want to delete.String myPath = @"C:\New\amit.txt";Now, use the File.Delete method to delete the file.File.Delete(myPath);The following is the complete code −Example Live Demousing System; using System.IO; public class Program {    public static void Main() {     ... Read More

Collection Initialization in C#

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 07:04:32

872 Views

Initialize Collection like class objects using collection initializer syntax.Firstly, set values for the Employee object −var emp1 = new Employee() { EID = 001, EmpName = "Tim", EmpDept = "Finance"}; var emp2 = new Employee() { EID = 002, EmpName = "Tom", EmpDept = "HR"};Now add this under a collection.IList ... Read More

Join, Sleep and Abort methods in C# Threading

Ankith Reddy

Ankith Reddy

Updated on 23-Jun-2020 06:58:34

596 Views

JoinBlocks the calling thread until a thread terminates, while continuing to perform standard COM and SendMessage pumping. This method has different overloaded forms.SleepMakes the thread pause for a period of time.AbortThe Abort method is used to destroy threads.Let us see an example of Join() in threading −Exampleusing System; using System.Diagnostics; ... Read More

Advertisements