Posts

Showing posts with the label c sharp

Reading and writing a CSV file in c # using csvHelper Example

Below is an example to write and read a csv file using csvHelper Library in c sharp. First you will have to include the csvHelper lib in to your project by going in to NuGet packages in your project and adding it. Once you don’t that you can examine the below program and implement the program. NB:- The below is just a snippet of code and the objects are not declared properly. So please make necessary changes before running the program. For writing a file- public void WriteFile( Data data)         {             String pathIp = “input_your_filePath”;             StreamWriter writeIp = new StreamWriter (pathIp);             CsvWriter cswIp = new CsvWriter (writeIp);                ...

How to return two objects at the same time in c sharp or Example of Tuple in c sharp

I found ‘Tuple’ to be  a very special , where you want to return two objects in the same function itself. I will explain with the help of below code. My aim in the below code is to return two objects in the same function. Lets consider those two objects are emp_Permanent and emp_Temp which I need when I call a function. These two objects are of the class Employee. public Tuple < Employee , Employee > splitEmployee( Employee employee)         {                                                                               // here I am splitting my employee obje...