.CS - File Extension for C# - C Sharp Files

Q

What is CS? CS, short name for C Sharp, is used as the file extension for C# (C Sharp) files. .CS files are text files that are used to store C# program source code. See the sample .CS file included below.

✍: FYIcenter.com

A

File Extension: .CS

MIME Type: text/plain

File Content: C Sharp

.CS files are C Sharp files, that are used to store C# program source code. Here is a sample .CS C Sharp file, TimeZone.cs:

/*
  This file is part of the Microsoft .NET Framework SDK Code Samples.
*/
using System;
using System.Collections;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace Microsoft.Samples.TimeZoneConvertCS {
  /// TimeZoneCollection
  /// implements a sorted list of TimeZones by reading the Windows 
  /// Registry (there's currently no other way to do it)
  public class TimeZoneList : System.Collections.ArrayList {
    public TimeZoneList() {
      //initialize the list
      this.Initialize();  
    }

    public TimeZone this[string name] {
      get {
        int i;
        for (i = 0; i < this.Count; i++) {
          if (((TimeZone)base[i]).StandardName == name) {
            break;
          }
        }
        if (i == this.Count) {
          return null;
        } else {
          return (TimeZone)base[i];
        }
      }
      set { base.Add(this); }
    }

    private void Initialize() {
      RegistryKey hKeyRoot;
      RegistryKey hKeyTZ;
      RegistryKey  hKey;
      TimeZone tz;
      String stTZKey;
      String[] KeySet;

      int i;
      int m_count;
      hKeyRoot = Registry.LocalMachine;
      // Hack Hack - reading the registry ...
      // first try with NT/2k/Xp key
      stTZKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones";
      hKeyTZ = hKeyRoot.OpenSubKey(stTZKey);
...      
       
      //now add all subkeys
      KeySet = hKeyTZ.GetSubKeyNames();
      m_count = hKeyTZ.SubKeyCount;
      for (i = 0; i <= (m_count - 1); i++)  {
        hKey = hKeyTZ.OpenSubKey(KeySet[i]);
        //... with some properties
        tz = new TimeZone(hKey);
        hKey.Close();
...

.CS C Sharp file sample: Click sample.cs to download.

Since .CS files are in text format, you can use Notepad or any text editor to create or modify them. No special software is needed.

For for information on how to use .CS C Sharp files, see links below:

2021-05-12, 29049👍, 1💬