Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Server Side Programming Articles - Page 2504 of 2650
 
			
			948 Views
The following is the difference between implicit and explicit type conversion −Implicit Type ConversionThese conversions are performed by C# in a type-safe manner.To understand the concept, let us implicitly convert int to long.int val1 = 11000; int val2 = 35600; long sum; sum = val1 + val2;Above, we have two integer variable and when we sum it in a long variable, it won’t show an error. Since the compiler does the implicit conversion on its own.Let us print the values now.Exampleusing System; using System.IO; namespace Demo { class Program { static void Main(string[] args) ... Read More
 
			
			2K+ Views
Internal Access SpecifierInternal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly.Any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.The following is an example −Exampleusing System; namespace RectangleApplication { class Rectangle { //member variables internal double length; internal double width; double GetArea() { return length * width; } ... Read More
 
			
			799 Views
Type conversion is converting one type of data to another type. Explicit conversions are done explicitly by users using the pre-defined functions and require a cast operator.Let us see an example to cast double to int −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { double a = 4563.56; int x; x = (int)a; Console.WriteLine(x); Console.ReadKey(); } } }To cast double to int, we perfomed explicit type casting −x = (int)a;
 
			
			311 Views
C# is a modern, general-purpose, object-oriented programming language developed by Microsoft.C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures.Here are the features of C# −Boolean ConditionsAutomatic Garbage CollectionStandard LibraryAssembly VersioningProperties and EventsDelegates and Events ManagementEasy-to-use GenericsIndexersConditional CompilationSimple MultithreadingLINQ and Lambda ExpressionsIntegration with Windows
 
			
			532 Views
Boxing convert value type to an object type. Let us see an example of boxing −int x = 50; object ob = x; // boxingIn boxing, the value stored on the stack is copied to the object stored on heap memory, whereas unboxing is the opposite.Boxing is useful in storing value types in the garbage-collected heap. It is implicit conversion of a value type to the type object.Let us see an example −Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { static void Main() { int x = 50; object ... Read More
 
			
			3K+ Views
To copy or clone a C# list, firstly set a list −List < string > list1 = new List < string > (); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); list1.Add("Four");Now declare a string array and use the CopyTo() method to copy.string[] arr = new string[20]; list1.CopyTo(arr);Let us see the complete code to copy a list into a one-dimensional array.Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { public static void Main() { List < string > list1 = new List < string > (); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); ... Read More
 
			
			504 Views
Generics allow you to write a class or method that can work with any data type.Write the specifications for the class or the method, with substitute parameters for data types. When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type. Generics is a technique that enriches your programs in the following ways −It helps you to maximize code reuse, type safety, and performance.You can create generic collection classes. The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace. You may use these generic ... Read More
 
			
			774 Views
Set the string array for the values −string[] names = new string[] {"Jack", "Tom"};Now using foreach array, write the content in the file −using (StreamWriter sw = new StreamWriter("names.txt")) { foreach (string s in names) { sw.WriteLine(s); } }The following is an example showing an array of streams to write text to a file −Exampleusing System; using System.IO; namespace FileApplication { class Program { static void Main(string[] args) { string[] names = new string[] {"Jack", "Tom"}; using (StreamWriter sw = ... Read More
 
			
			37K+ Views
Use the AddRange() method to append a second list to an existing list.Here is list one −List < string > list1 = new List < string > (); list1.Add("One"); list1.Add("Two");Here is list two −List < string > list2 = new List < string > (); list2.Add("Three"); ist2.Add("Four");Now let us append −list1.AddRange(list2);Let us see the complete code.Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { public static void Main() { List < string > list1 = new List < string > (); list1.Add("One"); list1.Add("Two"); ... Read More
 
			
			314 Views
A field marked "read-only", can only be set once during the construction of an object. It cannot be changed −Let us see an example.class Employee { readonly int salary; Employee(int salary) { this.salary = salary; } void UpdateSalary() { //salary = 50000; // Compile error } }Above, we have set the salary field as read-only.If you will change it, then a compile-time error will occur. The same is shown in the above example.Let us now see how to check whether an array is read-only or not −Exampleusing ... Read More