With a piece of code like this, the compiler complains on c.MyProperty:
MyClass c;
try { throw new Exception(); }
catch (Exception) { }
c.MyPr
The reason for this exception is that you've not assigned a default value for the variable e.g
if (Request.Files != null && Request.Files.Count > 0)
{
Image = Request.Files.AllKeys[0];
}
var stream = new FileStream(Image,FileMode.Open);
now the Image variable will give compiler error
Use of unassigned local variable 'Image'
That is due to the reason that there is possibility that condition becomes true and control will never get to know what the Image variable is . so either place an else block or assign a default value as below.
string Image = "";
if (Request.Files != null && Request.Files.Count > 0)
{
Image = Request.Files.AllKeys[0];
}
var stream = new FileStream(Image,FileMode.Open);