What are the uses of the implicit and explicit keywords in C#. implicit is used when we need implicit conversions between types. It works on value types and as well on reference types. The below code shows the use of implicit keyword. Create a class named Digit as below and note the two static methods … Continue reading C# – implicit & explicit keywords
Embedding Resources in Silverlight
This post explains how to embed a resource file in Silverlight and use it. For the example we’ll consider embedding a CSV file and using it. Copy the file inside the project under the appropriate path. In the properties of the file set the Build Action as Embedded Resource. The below sample code shows how … Continue reading Embedding Resources in Silverlight
Uploading a file to Azure Blob
Windows Azure storage provides flexible storage services. Blob storage is one of them which is used to store binary large objects. Windows Azure blob has the concepts of containers (which you can think like partitions of a disk). Containers are either private or public. Private containers are only accessible to the user and application developer … Continue reading Uploading a file to Azure Blob
HTTP Headers
This is a quick and a small post on reading the HTTP headers in ASP.NET. Code gets the HTTP header key – value pairs and write it to a text file. 1: protected void Page_Load(object sender, EventArgs e) 2: { 3: var headers = Request.Headers; 4: StreamWriter writer = new StreamWriter(Server.MapPath("~/data.txt")); 5: 6: foreach (var … Continue reading HTTP Headers
AES Cryptography
Contains the code for AES encryption and decryption in C#. 1: public byte [] EncryptText(string plainData) 2: { 3: RijndaelManaged rij = new RijndaelManaged(); 4: 5: rij.GenerateKey(); 6: _key = rij.Key; 7: 8: rij.GenerateIV(); 9: _intializationVector = rij.IV; 10: 11: ICryptoTransform encryptor = rij.CreateEncryptor(_key, _intializationVector); 12: 13: using (MemoryStream msEncrypt = new MemoryStream()) 14: { … Continue reading AES Cryptography
UI Updates – Part 2
ASP.NET ASP.NET UI updates are handles using Ajax. In this example it is described how to use the ASP.NET Ajax for the updates. In ASP.NET Ajax we can have update panel and make the updates via Ajax calls. Prepare your ASPX markup like below. 1: <body> 2: <form id="form1" runat="server"> 3: <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 4: … Continue reading UI Updates – Part 2
UI Updates – Part 1
Updating the UI is a problem and it is tricky. There are very few simple rules to follow. Let’s see Here we’ll see some smart ways to perform UI updates on Console applications, Windows Forms, WPF, ASP.NET, Silverlight, Windows Phone and Windows Store apps. Console Applications Do they have UI ? No. But we’ll check … Continue reading UI Updates – Part 1
Delegates
Methods are delegate types. It is that simple. Since delegates are types in .NET we can use any method as types, that means we can pass methods as parameters and we can return methods. The below code shows different ways we can instantiate a delegate. 1: namespace DelegatesVsInterfaces 2: { 3: public delegate string MyDelegate(string … Continue reading Delegates