C# (C Sharp) is a high-level, object-oriented programming language developed by Microsoft. It is a versatile language that is commonly used for developing Windows desktop applications, web applications, and games.
Example 1: Reading a CSV File using C# In this example, we will read a CSV file using the C# programming language. We will use the CSV Helper package, which is a fast and reliable library for working with CSV files.
using System; using System.Collections.Generic; using System.IO; using CsvHelper;
class Program { static void Main(string[] args) { string csvPath = "path/to/csv/file.csv"; using (var reader = new StreamReader(csvPath)) using (var csv = new CsvReader(reader, System.Globalization.CultureInfo.InvariantCulture)) { csv.Configuration.HeaderValidated = null; csv.Configuration.MissingFieldFound = null; var records = csv.GetRecords(); foreach (var record in records) { Console.WriteLine(record); } } } }
Package/Library: CsvHelper
Example 2: Creating a REST API using C# In this example, we will create a simple REST API using C#. We will use the ASP.NET Core framework, which is a cross-platform framework for building web applications.
using System; using Microsoft.AspNetCore.Mvc;
namespace SampleAPI.Controllers { [ApiController] [Route("[controller]")] public class HelloWorldController : ControllerBase { [HttpGet] public IActionResult Get() { return Ok("Hello World!"); } } }
Package/Library: ASP.NET Core
C# (CSharp) skill - 38 examples found. These are the top rated real world C# (CSharp) examples of skill extracted from open source projects. You can rate examples to help us improve the quality of examples.