Blog Stats
  • Posts - 742
  • Articles - 5
  • Comments - 197
  • Trackbacks - 25

 

CSharp

FastSharp - Write it, Execute it

Ricordo che un po' di tempo fa c'era in giro un tool simile. In sostanza, si tratta di un piccolo tool che permette di scrivere codice C# e di farlo eseguire senza la necessità di dover aprire tutte le volte Visual Studio e creare un progetto: Last year I wrote this program which I named FastSharp.  It is a text editor which lets you compile and run C# code that would normally exist inside a method.  The inspiration for this came from getting tired of opening up Visual Studio and creating a project when all I want to do...

30 Minutes Intro to C# 3.0 Language Enhancements

Breve e conciso, adatto a farsi una idea per chi ancora non ce l'ha: During a 30 minutes Chopsticks video, Bart De Smet guides you through the most important languages enhancements you'll find in Visual Studio 2008. Fonte: Tom's MSDN Belux Corner : 30 Minutes Intro to C# 3.0 Language Enhancements Technorati Tags: C#,Visual Studio 2008

The C# ?? null coalescing operator (and using it with LINQ) - ScottGu's Blog

Qualche giorno fa, parlavo su questo blog dell'operatore ?? di C#. Oggi, ScottGu fa, sul sui blog, un semplice esempio di utilizzo in LINQ: One of the subtle (but cool) language features of C# is the ?? "null coalescing" operator.  This provides a nice, terse way to check whether a value is null, and if so return an alternate value. Simple Example Usages Several folks have blogged about the ?? operator in the past - read here, here, here, and here for some previous examples on how to use it.  Simply put, the ?? operator checks whether the...

L'operatore ?? (2)

L'altro giorno parlavo, in questo post, dell'operatore ?? ma, lo ammetto, non mi sono spinto fino all'IL per capirne le differenze con l'operatore ?.A farlo ci ha pensato qualcun'altro:    One thing that I do want to point about this technique is that it is a bit more (slightly) than syntactic sugar - as it actually generates different IL than the same task implemented with the ternary operator.  For example, here is some typical ternary-based code... Leggi il resto alla fonte: Need a New Title : How Did I Miss This? Tags: .Net CSharp

Properties vs public fields redux...

Di una cosa simile, ne discutevo tempo fa con un paio di amici.  L'argomento citato in questo post è leggermente diverso ma il concetto è chiaro: evitare di esporre l'accesso diretto ai campi (pubblici) di un oggetto, ma incapsularlo un una proprietà. Il motivo lo spiega Eric Gunnerson in questo post (da cui cito): The reason that the library design guidelines suggest you write a property here is that it is important that libraries be easily versioned. If you put a property in there ahead of time, you can change the property implementation without requiring users to recompile their code. Sebbene più avanti lo stesso Eric dice: But, if the...

Properties vs public fields redux...

Di una cosa simile, ne discutevo tempo fa con un paio di amici.  L'argomento citato in questo post è leggermente diverso ma il concetto è chiaro: evitare di esporre l'accesso diretto ai campi (pubblici) di un oggetto, ma incapsularlo un una proprietà. Il motivo lo spiega Eric Gunnerson in questo post (da cui cito): The reason that the library design guidelines suggest you write a property here is that it is important that libraries be easily versioned. If you put a property in there ahead of time, you can change the property implementation without requiring users to recompile their code. Sebbene più avanti lo stesso Eric dice: But, if the...

GetTempFileName e GetRandomFileName

Decisamente molto utili in applicazioni Windows Forms: GetTempFileName: http://msdn2.microsoft.com/it-it/library/system.io.path.gettempfilename(VS.80).aspx GetRandomFileName: http://msdn2.microsoft.com/it-it/library/system.io.path.getrandomfilename%20(VS.80).aspx Tags: .Net CSharp Windows Forms

L'operatore ?? (C#)

Non l'ho visto utilizzare spesso e, lo ammetto, anche io ogni tanto me ne dimentico (per fortuna che c'è Resharper che me lo ricorda ). Si tratta dell'operatore ?? introdotto con il .NET Framework 2.0. Lo scopo è decisamente semplice: restituire un valore di dafault se il tipo è nullo, altrimenti restituire il valore corretto. Il tutto in forma molto compatta. In sostanza, anzichè scrivere un if o utilizzare l'operatore condizionale ? (in caso di valutazione dei null) in questo modo: 1: int? x = 0; 2: int y = (x == null) ? -1 : x; possiamo scrivere più semlicemente: ...

Asymmetric Accessor Accessibility (C#)

Spesso si dimentica che i metodi get e set di una propery possono essere "asimmetrici".  Siamo tutti abituati (colpa degli snippets di codice?) a settare le proprietà in questo modo: 1: public string Name 2: { 3: get { return name; } 4: set { name = value; } 5: } Ma nulla ci impedisce di fare una cosa del tipo: 1: public string Name 2: { 3: get { return name; } 4:...

Delayed Signing

Quando abbiamo la necessità di riutilizzare la stessa versione di un componente che abbiamo scritto in più applicazioni, viene naturale pensare alla GAC (Global Assemby Cache). Essa presuppone che l'assembly che andiamo a mettere al suo interno sia Strong Named, ossia sia dotato di un nome univoco composto da: nome del file versione culture publik key (o hash della chiave) Per fornire ad un assebly uno strong name, abbiamo bisogno di una coppia di chiavi (pubblica e privata) ottenibili dal tool da riga di comando...

Full CSharp Archive

 

 

Copyright © Mighell |  Theme by Mighell.