Scroll to top

.NET Framework


Category

.NET Framework : Getting started with .NET Framework

Hello World in C# using System; class Program { // The Main() function is the first function to be executed in a program static void Main() { // Write the string…

Curious Bot December 1, 2018

.NET Framework : ReadOnlyCollections

Creating a ReadOnlyCollection Using the Constructor A ReadOnlyCollection is created by passing an existing IList object into the constructor: var groceryList = new…

Curious Bot December 1, 2018

.NET Framework : Garbage Collection

In .Net, objects created with new() are allocated on the managed heap. These objects are never explicitly finalized by the program that uses them; instead, this…

Curious Bot December 1, 2018

.NET Framework : ADO.NET

ADO(ActiveX Data Objects).Net is a tool provided by Microsoft which provides access to data sources such as SQL Server, Oracle, and XML through its components. .Net…

Curious Bot December 1, 2018

.NET Framework : Custom Types

Struct Definition Structs inherit from System.ValueType, are value types, and live on the stack. When value types are passed as a parameter, they are passed by value.…

Curious Bot December 1, 2018

.NET Framework : Platform Invoke

Calling a Win32 dll function using System.Runtime.InteropServices; class PInvokeExample { [DllImport("user32.dll", CharSet = CharSet.Auto)] public static…

Curious Bot December 1, 2018

.NET Framework : Stack and Heap

Value types in use Value types simply contain a value. All value types are derived from the System.ValueType class, and this includes most of the built in types.…

Curious Bot December 1, 2018

.NET Framework : VB Forms

Hello World in VB.NET Forms To show a message box when the form has been shown: Public Class Form1 Private Sub Form1_Shown(sender As Object, e As EventArgs) Handles…

Curious Bot December 1, 2018

.NET Framework : Strings

Count distinct characters If you need to count distinct characters then, for the reasons explained in Remarks section, you can’t simply use Length property…

Curious Bot December 1, 2018

.NET Framework : Parallel processing using .Net framework

This Topic is about Multi core programming using Task Parallel Library with .NET framework. The task parallel library allows you to write code which is human readable…

Curious Bot December 1, 2018

.NET Framework : Settings

AppSettings from ConfigurationSettings in .NET 1.x Deprecated usage The ConfigurationSettings class was the original way to retrieve settings for an assembly in…

Curious Bot December 1, 2018

.NET Framework : System.IO

Reading a text file using StreamReader string fullOrRelativePath = "testfile.txt"; string fileData; using (var reader = new StreamReader(fullOrRelativePath))…

Curious Bot December 1, 2018

.NET Framework : Code Contracts

Preconditions Preconditions allows methods to provide minimum required values for input parameters Example… void DoWork(string input) { Contract.Requires(!string.IsNullOrEmpty(input));…

Curious Bot December 1, 2018

.NET Framework : System.Diagnostics

Stopwatch This example shows how Stopwatch can be used to benchmark a block of code. using System; using System.Diagnostics; public class Benchmark : IDisposable…

Curious Bot December 1, 2018

.NET Framework : TPL Dataflow

Posting to an ActionBlock and waiting for completion // Create a block with an asynchronous action var block = new ActionBlock<string>(async hostName =>…

Curious Bot December 1, 2018

.NET Framework : System.Runtime.Caching.MemoryCache (ObjectCache)

Adding Item to Cache (Set) Set function inserts a cache entry into the cache by using a CacheItem instance to supply the key and value for the cache entry. This…

Curious Bot December 1, 2018