Click here to Skip to main content
15,867,308 members
Home / Discussions / C#
   

C#

 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
F-ES Sitecore22-Aug-16 2:04
professionalF-ES Sitecore22-Aug-16 2:04 
JokeRe: Visual Studio - how to change "var" to corresponding class Pin
Richard MacCutchan22-Aug-16 2:09
mveRichard MacCutchan22-Aug-16 2:09 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Maarten197722-Aug-16 2:35
Maarten197722-Aug-16 2:35 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Pete O'Hanlon22-Aug-16 2:45
subeditorPete O'Hanlon22-Aug-16 2:45 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Maarten197722-Aug-16 3:11
Maarten197722-Aug-16 3:11 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Pete O'Hanlon22-Aug-16 3:25
subeditorPete O'Hanlon22-Aug-16 3:25 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
F-ES Sitecore22-Aug-16 3:16
professionalF-ES Sitecore22-Aug-16 3:16 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Richard Deeming22-Aug-16 4:26
mveRichard Deeming22-Aug-16 4:26 
F-ES Sitecore wrote:
you can't discern the types simply by looking at them

Agreed, for things like:
C#
var frob = DoSomething();

But, for cases where the type is obvious, var cuts down on the clutter:
C#
var myFoos = new Dictionary<string, Foo>();

// Vs:
// Dictionary<string, Foo> myFoos = new Dictionary<string, Foo>();

However, if for some reason you need the variable type to be an interface or a base type, var isn't a good option:
C#
IDictionary<string, Foo> myFoos = new Dictionary<string, Foo>();

// Vs:
// var myFoos = (IDictionary<string, Foo>)new Dictionary<string, Foo>();


Like almost anything, var has sensible uses and no-so-sensible uses. It's up to the developer to decide which is which! Smile | :)



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: Visual Studio - how to change "var" to corresponding class Pin
#realJSOP25-Aug-16 5:46
mve#realJSOP25-Aug-16 5:46 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Maarten197725-Aug-16 6:51
Maarten197725-Aug-16 6:51 
GeneralRe: Visual Studio - how to change "var" to corresponding class Pin
Richard Deeming22-Aug-16 2:06
mveRichard Deeming22-Aug-16 2:06 
Questionbrowse ith records on the GridView if errors rerun record or run next record ? Pin
Member 245846719-Aug-16 17:59
Member 245846719-Aug-16 17:59 
AnswerRe: browse ith records on the GridView if errors rerun record or run next record ? Pin
OriginalGriff19-Aug-16 21:43
mveOriginalGriff19-Aug-16 21:43 
AnswerRe: browse ith records on the GridView if errors rerun record or run next record ? Pin
Richard MacCutchan19-Aug-16 22:00
mveRichard MacCutchan19-Aug-16 22:00 
GeneralRe: browse ith records on the GridView if errors rerun record or run next record ? Pin
Member 245846720-Aug-16 17:57
Member 245846720-Aug-16 17:57 
QuestionAT+CREG? command Pin
Mike Angelo Gunao Navales18-Aug-16 22:59
Mike Angelo Gunao Navales18-Aug-16 22:59 
AnswerRe: AT+CREG? command Pin
OriginalGriff18-Aug-16 23:32
mveOriginalGriff18-Aug-16 23:32 
GeneralRe: AT+CREG? command Pin
Mike Angelo Gunao Navales19-Aug-16 1:10
Mike Angelo Gunao Navales19-Aug-16 1:10 
Questionvisual studio 2013 community edition and uml modeling Pin
Tridip Bhattacharjee18-Aug-16 21:52
professionalTridip Bhattacharjee18-Aug-16 21:52 
AnswerRe: visual studio 2013 community edition and uml modeling Pin
Richard MacCutchan18-Aug-16 22:25
mveRichard MacCutchan18-Aug-16 22:25 
AnswerRe: visual studio 2013 community edition and uml modeling Pin
Nathan Minier19-Aug-16 1:00
professionalNathan Minier19-Aug-16 1:00 
AnswerRe: visual studio 2013 community edition and uml modeling Pin
Gerry Schmitz20-Aug-16 8:12
mveGerry Schmitz20-Aug-16 8:12 
QuestionHow to get the currently opened directory in Windows Explorer in .net Pin
srikrishnathanthri17-Aug-16 19:28
srikrishnathanthri17-Aug-16 19:28 
AnswerRe: How to get the currently opened directory in Windows Explorer in .net Pin
Richard MacCutchan17-Aug-16 21:35
mveRichard MacCutchan17-Aug-16 21:35 
Questionconcatenative approach to TTS Pin
Member 1266621417-Aug-16 4:28
Member 1266621417-Aug-16 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.