Let’s say the following is the number −int a = 12250;You can work around the following ways to get a number in hexadecimal format −{0:x} {0:x8} {0:X} {0:X8}Here is the code −Example Live Demousing System; class Demo { static void Main() { int a = 12250; Console.WriteLine("{0:x}", a); Console.WriteLine("{0:x8}", a); Console.WriteLine("{0:X}", a); Console.WriteLine("{0:X8}", a); } }Output2fda 00002fda 2FDA 00002FDA
To create a tuple, use the Tuple.Create method.Here we have set a tuple with a string and int −var myTuple = Tuple.Create("marks", 100);The following is an example that creates a tuple using Tuple.Create and displays the elements in a single line in C# −Example Live Demousing System; class Demo { static void Main() { var myTuple = Tuple.Create("marks", 100); Console.WriteLine(myTuple); } }Output(marks, 100)
With C#, you can easily set a 6-item tuple.The following is a 6-item tuple −var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000);above, we have tuple for string, string array and int as shown below −TupleHere is the complete code −Example Live Demousing System; class Demo { static void Main() { var myTuple = new Tuple("electronics", new string[] { "shoes", "clothing#", "accessories" }, 100, 250, 500, 1000); // Displaying Item 1 Console.WriteLine(myTuple.Item1); // Displaying Item 5 Console.WriteLine(myTuple.Item5); // Displaying Item 6 Console.WriteLine(myTuple.Item6); } }Outputelectronics 500 1000
To get the last write time of a file in C#, use the LastWriteTime() method.For this, use the FileInfo as well as DateTime classes.Create an object of each −FileInfo file = new FileInfo("amit.txt"); DateTime dt = file.CreationTime; dt = file.LastWriteTime;Let us see the complete code −Example Live Demousing System.IO; using System; public class Program { public static void Main() { using (StreamWriter sw = new StreamWriter("amit.txt")) { sw.WriteLine("Welcome!"); } FileInfo file = new FileInfo("amit.txt"); // file creation time DateTime dt = ... Read More
To get the last access time of a file in C#, use the LastAccessTime() method.For this, use the FileInfo as well as DateTime classes.Create an object of each −FileInfo file = new FileInfo("new.txt"); DateTime dt = file.CreationTime; dt = file.LastAccessTime;Let us see the complete code −Example Live Demousing System.IO; using System; public class Program { public static void Main() { using (StreamWriter sw = new StreamWriter("quiz.txt")) { sw.WriteLine("Quizzes!"); } FileInfo file = new FileInfo("quiz.txt"); // last access time DateTime dt = file.LastAccessTime; Console.WriteLine(dt); } }Output9/5/2018 5:21:43 AM
To get the creation time of a file in C#, use the CreationTime() method.For this, use the FileInfo as well as DateTime classes.Create an object of each −FileInfo file = new FileInfo("new.txt"); DateTime dt = file.CreationTime;Let us see the complete code −Example Live Demousing System.IO; using System; public class Program { public static void Main() { using (StreamWriter sw = new StreamWriter("qa.txt")) { sw.WriteLine("Questions and Answers!"); } FileInfo file = new FileInfo("qa.txt"); // file creation time DateTime dt = file.CreationTime; Console.WriteLine(dt); } }Output9/5/2018 5:20:03 AM
To declare optional function parameters in JavaScript, use the “default” arguments.ExampleYou can try to run the following code to declare optional parameters − // default is set to 1 function inc(val1, inc = 1) { return val1 + inc; } document.write(inc(10,10)); document.write(""); document.write(inc(10));
Set lowercase suffixes for literals such as u, l, ul, f, etc.// l for long long a = 29876l;It can be used on literal numbers as well. It tells the compiler that the literal is of a specific type.The following is an example −Example Live Demousing System.IO; using System; public class Program { public static void Main() { long a = 29876l; float b = 95.10f; Console.WriteLine(a); Console.WriteLine(b); } }On running the above example, you will get the following output. With that, you will also get a ... Read More
The Function() constructor expects any number of string arguments. The last argument is the body of the function - it can contain arbitrary JavaScript statements, separated from each other by semicolons.ExampleYou can try to run the following code to invoke a function with new Function Constructor − var func = new Function("x", "y", "return x*y;"); function multiplyFunction(){ var result; result = func(15,35); document.write ( result ); } Click the following button to call the function
To specify number types, use suffixes in C#. Literal number suffixes are numeric suffixes.For example, for long type −// long suffix long val1 = 29345L;For double type −// double suffix double val2 = 297.325D; Console.WriteLine(val2);Let us see more examples −Example Live Demousing System.IO; using System; public class Program { public static void Main() { // long suffix long val1 = 29345L; Console.WriteLine(val1); // decimal suffix decimal val5 = 3245.5678M; Console.WriteLine(val5); // double suffix double val2 = 297.325D; Console.WriteLine(val2); // float suffix float val3 = 250.35F; Console.WriteLine(val3); // unsigned suffix uint val4 = 3456U; Console.WriteLine(val4); } }Output29345 3245.5678 297.325 250.35 3456
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP