Category Archives: C#

Json Parser

One of my friend asked me what can be a good JSON parser. In past i’ve used Json.Net from NewtonSoft. It is a good an very strong library to use. Is simple to implement as you want.

I’ve attached an project sample, with what i’ve used in my work project. Project for test. Don’t forget to modify it as you want.  

Posted in C#.

EAN13 Middle Check Digit

In one of my job project, i’ve needed to implement the middle check digit for EAN13. If you search on internet nobody will tell you how to determine the digit. On of my foreign collegues from Bizerba, gave me the mecanism for the digit calculation. I’ve attached the source code for my implemention. Enjoy and don’t forget to modify it as you need. πŸ™‚

Posted in C#.

Business Entity, Data Access Object,Business Component

In this article i will present my implementation for Business Entity and Data Access Object. Generally the access to database object, should be separated in 2 or more layers. In my case i’ve created only 2 layers – DAO and BC. Business Entity – according to MSDN article, the object should be an representation of data. In my case i’ve created an CommonDatabase class who implements ICloneable and IDisposable interfaces. This object is always Serializable.

The Business Entity Object is defined as an inherit object from CommonDatabase:

The Data Access Object – is generally an class who can access the database and execute the Insert,Update,Delete,Select functions. As following …

Continue reading

Posted in C#.

Expando Objects

Since C# 4.0 .Net Framework permits creation of dynamic object from xml content. On MSDN is presented an article about this new type. πŸ™‚ This type i’ve used in a big project in order to load an xml, and use the members from the tags. I’ve created an static class who has only an public method who returns an ExpandoObject. Here is my implementation:

The usage of this class is presented next:

As you can see any type of xml content can be loaded, and then the “dynamic” object can be used like an object with members. For this type of data i’ve found an object dumper so …

Continue reading

Posted in C#.

Cross Thread Utility

IF you want to update some information in windows form control from another thread please use the following class. πŸ™‚ IF you receive the error : “Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on ….” use the following class. πŸ™‚

This class can be used from .Net 3.5 version. How to use it:

I consider that is a good class, to use it in multi threaded aplications. Don’t forget to modify it as you want. πŸ™‚

Posted in C#.

C# Operator Overloading

This is my first C# operator overloading implementation that can be used in many specific projects. The tutorial from MSDN it shows only a basic class that implements the operators. In this case the class presented on MSDN doesn’t have any usability, other than learning how to implement the operator overloading. Next i present you an class who can be used as is. πŸ˜€

Next i show you an usage . The code doesn’t need any comments – is simple. The variable info can be used like an string, and using the operatorΒ  “+” you can add byte array from any function who returns this kind of data. At …

Continue reading

Posted in C#.

Hex – Byte Class

The following class i’ve used in an fiscal printer implementation for my job. This static class only is a wraper for byte values.

Can be used as you want. For me it was very important to use it because it is much simpler to see the text other then the effective values. The usage of this class:

Enjoy and don’t forget to modify it as you want. πŸ™‚  

Posted in C#.