Web- und Software Development

Archive for the 'CSharp' Category

ViewModelProperty – Visual Studio Snippet

Folgendes Snippet erstellt bei der Eingabe von vmprop ein ViewModelProperty 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 #region ViewModelProperty ViewModelPropertyName private string _privatePropertyName; public string ViewModelPropertyName { get { return _privatePropertyName; } set { _privatePropertyName = value; RaisePropertyChanged(m => m.ViewModelPropertyName); } } #endregion Kopiert wird das Snippet [...]

Read the rest of this entry »

Visual C# 2010 – OpenBook

Auf Galileocomputing steht das umfassende Handbuch für Visual C# 2010 zum kostenlosen Download bereit. Wie immer Vielen Dank an Galileocomputing! Das Buch mit den 1295 Seiten, kann auch gebunden erworben werden.

Read the rest of this entry »

Doppelte Einträge aus einer DataTable entfernen | LinqExtension

Folgende LINQExtension* enternt doppelte Einträge einer DataTable und gibt diese zurück 1 2 3 4 5 6 7 8 9 10 public static DataTable DistinctDataTable(this DataTable table) { var resultTable = table.Clone(); IEnumerable<DataRow> uniqueElements = table.AsEnumerable().Distinct(DataRowComparer.Default); foreach (var row in uniqueElements) { resultTable.ImportRow(row); } return resultTable; } Verwendung: DataTable resultTable = mainTable.DistinctDataTable(); Viel Spaß beim [...]

Read the rest of this entry »

DataSetExtension – ForEach | C# Quicky

Wenn man eine DataRow aus einer DataTable eines DataSets in eine andere DataTable kopieren möchte, geht man durch die entsprechenden DataTable und kopiert diese. 1 2 3 4 foreach (DataRow row in kundeDataTable.Rows) { dataSetResult.Tables["Kunde"].ImportRow(row); } Um sich ein paar Zeilen zu sparen, kann man an das DataRow Array eine ExtensionMethod anhängen. Hierfür implementieren wir [...]

Read the rest of this entry »