Posts

Recent post

Members of datatype and DateTime, TimeSpan

Image
In this article we will see members of C# datatypes. Members of datatype Members of numerical datatype Experimenting with the intrinsic C# data types, understand that the numerical types of .NET support MaxValue and MinValue properties that provide information regarding the range a given type can store. In addition to the MinValue/MaxValue properties, a given numerical system type may define further useful members. For example, the System.Double type allows you to obtain the values for epsilon and infinity which might be of interest to those of you with a mathematical flare. Lets understand that by a simple program: Program using System; public class ConsoleApp { public static void Main(string[] args) { Console.WriteLine("Members of numerical datatype:"); Console.WriteLine("Max value of Int: {0}",int.MaxValue); Console.WriteLine("Min value of Int: {0}",int.MinValue); Console.WriteLine("

Datatype and keyword

Image
Like any programming language, C# defines keywords for fundamental data types, which are used to represent local variables, class data member variables, method return values, and parameters. Unlike other programming languages, however, these keywords are much more than simple compiler- recognized tokens. Rather, the C# data type keywords are actually shorthand notations for full-blown types in the System namespace. Table lists each system data type, its range, the corresponding C# keyword, and the type’s compliance with the common language specification (CLS). C# keyword System type Range Meaning CLS complaint? bool System.Boolean true or false Represents truth or falsity Yes sbyte System.SByte -128 to 127 signed 8-bit number No byte System.Byte 0 to 255 Unsigned 8-bit

System.Console

Image
It is true that a console user interface (CUI) may not be as enticing as a graphical user interface (GUI) or web application, restricting the early examples to console programs will allow you to keep focused on the syntax of C# and the core aspects of the .NET platform, rather than dealing with the complexities of building desktop GUIs or web sites.As its name implies, the Console class encapsulates input, output, and error-stream manipulations for console-based applications. As you can see in below table the Console class does provide some members that can spice up a simple command-line application, such as the ability to change background and foreground colors and issue beep noises in a variety of frequencies. Members of System.Console Member Meaning Beep() This method forces the console to emit a beep of a specified frequency and duration. BackgroundColor,ForegroundColor These properties

System.Environment

Image
Environment class allows you to obtain a number of details regarding the operating system currently hosting your .NET application using various static members. To illustrate the usefulness of System.Environment, update your Main() method to call a helper method named EnvironmentDetails() . Properties Meaning ExitCode Gets or sets the exit code for the application Is64BitOperatingSystem Returns a bool to represent whether the host machine is running a 64-bit OS MachineName Gets the name of the current machine NewLine Gets the newline symbol for the current environment SystemDirectory Returns the full path to the system directory UserName Returns the name of the user that started this application Version Returns a Version object that represents the version of the .NET platform Create EnvironmentDetails() method in class under Main() method and call this method in Main() method. Program

How to make editor with live changes of HTML, CSS and JS?

Image
Have you heard about Text editor with live changes of HTML , CSS and JAVASCRIPT ? Get a real-time connection to your output. Make changes to CSS and HTML and JS you'll instantly see those changes on screen. Number of that kind of editors are available online. In this article we will see how it works ? code is given below: HTML <table> <tr> <td> <pre id="html" class="content" contenteditable> </pre> </td> <td rowspan="3" id="Output"> <iframe id="output"></iframe> </td> </tr> <tr> <td> <pre id="css" class="content" contenteditable> </pre> </td> </tr> <tr> <td> <pre id="js" class="content" contenteditable> </pre> </td> </tr> </table> CSS pre::before{ font-size: 16px; content:

Command line argument

Image
With the first introduction post of C# you can understand the return value of the Main() method, let’s examine the incoming array of string data. Assume that you now want to update your application to process any possible command-line parameters. One way to do so is using a C# for loop. We will see for loop in C# in later article. Accessing command line arguments with for loop Program using System; public class CLA { public static void Main(string[] args) { //this loop prints any number of given command line arguments for(int i=0; i<args.Length; i++) { Console.WriteLine("arg-" + i + " = " + args[i]); } } } Output F:\Code\Algorithm>csc CLA.cs F:\Code\Algorithm>CLA tangled java elaborately arg-0 = tangled arg-1 = java arg-2 = elaborately Explanation Here, you are checking to see whether the array of strings contains some number of items using the Length property of Sys

Building blocks of .NET

Image
In this article we view three key (and interrelated) topics that make it all possible: the CLR, CTS, and CLS . Common Language Runtime From a programmer’s point of view, .NET can be understood as a runtime environment and a comprehensive base class library. The runtime layer is properly referred to as the Common Language Runtime , or CLR. The primary role of the CLR is to locate, load, and manage .NET objects on your behalf. The CLR also takes care of a number of low-level details such as memory management, application hosting, coordinating threads, and performing basic security checks (among other low-level details). Common Type System Another building block of the .NET platform is the Common Type System , or CTS. The CTS specification fully describes all possible data types and all programming constructs supported by the runtime, specifies how these entities can interact with each other, and details how they are represented in the .NET metadata format. Common Languag