Programmierbeispiele



Viel Spaß beim Strebern



Folienvortrag Objektorientiertes Programmieren



Es gibt doch Bits in der Welt von C#


      // Stellt ein Array Zeile für Zeile dar;
      // die Spalten gelesen ergeben0,1,2,3 usw.
      // Zeile1 Bit: 0,8,16,...
      // Zeile2 Bit: 1,9,17,...
      byte[] Daten = {0,1,2,3,4,5,6,7,8,9,10,1,12,13,14,15};
      BitArray ba  = new BitArray(Daten);
      for (int row = 0; row<8; row++){
      	Console.WriteLine();
      	for (int col = 0; col<16; col++){
        	int val = ba[col*8+row]?1:0;
        	Console.Write(val);
      	}
      	Console.WriteLine();
      
      }

Programm-Konfigurationen abspeichern

  public class Configuration
	  {
	     int _Version;
	     string _StringItem;
	     int _IntItem;
	
	     public Configuration()
	      {
	        _Version = 1;
	        _StringItem = "";
	        _IntItem = -1;
	      }
	     public static void Serialize(string file, Configuration c)
	      {
	        System.Xml.Serialization.XmlSerializer xs 
	           = new System.Xml.Serialization.XmlSerializer(c.GetType());
	        StreamWriter writer = File.CreateText(file);
	        xs.Serialize(writer, c);
	        writer.Flush();
	        writer.Close();
	      }
	     public static Configuration Deserialize(string file)
	      {
	        System.Xml.Serialization.XmlSerializer xs 
	           = new System.Xml.Serialization.XmlSerializer(
	              typeof(Configuration));
	        StreamReader reader = File.OpenText(file);
	        Configuration c = (Configuration)xs.Deserialize(reader);
	        reader.Close();
	        return c;
	      }
	     public int Version
	     {
	        get { return _Version; }
	        set { _Version = value; }
	      }
	     public string StringItem
	     {
	        get { return _StringItem; }
	        set { _StringItem = value; }
	      }
	     public int IntItem
	     {
	        get { return _IntItem; }
	        set { _IntItem = value; }
	      }
	
	   }



IEnumerator<KeyValuePair<string, DictEntry>> enum1 = NewDictionary.GetEnumerator();

while (enum1.MoveNext()){

KeyValuePair<string,DictEntry> kvp2 = enum1.Current;

string s = kvp2.Key+ kvp2.value;

}