Extracting information from a text using Regex and Match in C# .NET

Occasionally you need to extract some information from a free-text form. Consider the following text:

First name: Elvis
Last name: Presley
Address: 1 Heaven Street
City: Memphis
State: TN
Zip: 12345

Say you need to extract the full name, the address, the city, the state and the zip code into a pipe-delimited string. The following function is one option:

Read more of this post

Using isolated storage for application-specific data in C# .NET

There’s a special storage location for a .NET application on Windows that is allocated to that application. It’s called isolated storage and it’s an optimal place to store files by an application that doesn’t have full access to the file system. Writing to and reading from isolated storage doesn’t require any extra security check. An application without full access to the file system will be able to use its allocated slot in isolated storage and nothing else. It’s an ideal mechanism for storing e.g. application state.

However, don’t confuse isolated storage with file security. It is still a “normal” location on disk with a file path. A typical location is under users/[username]/appdata/local. Therefore you or full-trust applications can still find and modify the files saved in isolated storage. However, limited-trust applications won’t be able to access any other part of the file system.

Read more of this post

Creating temporary files on Windows using C# .NET

It’s trivial to create a temporary file using the Path class in .NET. Let’s first see how to find the path to the current user’s temp folder:

string tempFolderPath = Path.GetTempPath();

In my case it returns C:\Users\andras.nemes\AppData\Local\Temp\ which is the same as the value of the TEMP environment variable at the user level on my PC.

Read more of this post

Finding all WMI class properties with .NET C#

In this post we saw how to enumerate all WMI – Windows Management Intrumentation – namespaces and classes. Then in this post we saw an example of querying the system to retrieve all local drives:

Read more of this post

Structurally compare two arrays in .NET

In this post we saw how to determine if two arrays are structurally equal in .NET. Two arrays are said to be structurally equal if they contain the same elements in the same order.

Structural equality has a comparison counterpart: IStructuralComparable. It determines if an array comes before or after or is equal to another array based on the elements within it.

Read more of this post

TCP level communication with C# .NET with a server and a client

.NET has the necessary objects to enable TCP-level messaging in the System.Net.Sockets namespace. The key objects to build an extremely simple TCP server are TcpListener and Socket. The TCP client and server can communicate in a stream-like fashion over the network using the NetworkStream object.

Here’s an example of how a TCP server can ingest the message of a single client:

Read more of this post

Type conversion example in C# .NET using the IConvertible interface

In this we saw how to convert between numeric types explicitly and implicitly. There are other ways to implement conversions in C#. You must have come across the System.Convert static methods such as System.ConvertToInt32 or System.ConvertToByte.

You can implement your own conversions by implementing the IConvertible interface. Consider the following object:

public class House
{
	public double Area { get; set; }
	public int NumberOfRooms { get; set; }
	public string Address { get; set; }
	public bool ForSale { get; set; }
        public DateTime DateBuilt { get; set; }
}

Read more of this post

ultimatemindsettoday

A great WordPress.com site

iReadable { }

.NET Tips & Tricks

Robin Sedlaczek's Blog

Love to use Microsoft Technologies

HarsH ReaLiTy

A Good Blog is Hard to Find

Ricos Blog zu Softwaredesign- und architektur

Ideen und Gedanken rund um Softwaredesign und -architektur, Domain-Driven Design, C# und Windows Azure

the software architecture

thoughts, ideas, diagrams,enterprise code, design pattern , solution designs

Technology Talks

on Microsoft technologies, Web, Android and others

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

Anything around ASP.NET MVC,WEB API, WCF, Entity Framework & AngularJS

Cyber Matters

Bite-size insight on Cyber Security for the not too technical.

Guru N Guns's

OneSolution To dOTnET.

Johnny Zraiby

Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

%d bloggers like this: