c# - Setting variable 'as type' -


came across snippet of code today:

eventfeed feed = null; feed = service.query(eventquery) eventfeed; 

why as eventfeed @ end? return type of function eventfeed, i'm struggling see benefit of such statement.

i found difficult search problem i'm asking on here. advantages writing line this?

feed might declared eventfeed result of service.query(eventquery) may not be.

using as stops exception being thrown , end null instead if result of expression cannot cast eventfeed.

you can read more as here - http://msdn.microsoft.com/en-us/library/cscsdfbt(v=vs.71).aspx


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -