T
Tony Johansson
Hi!
Here is some code and I suspect that this code is coded wrong because this
code doesn't make sense with how the using is used here. I suspect that it
should have been codes like see at the bottom.
Or is it something that I miss here saying that the way they use the using
here is perfectly correct and valid ?
The book I read say the following about the using. It says "The using
statement specifies that the image resources should be automatically
displosed at the end of the using block"
ResXResourceWriter rw = new ResXResourceWriter("Demo.resx");
using(Image image = Image.FromFile("bell.gif"))
{
rw.AddResource("Mylogo",image);
rw.AddResource("Title","Professional C#");
rw.AddResource("Chapter", "Localization");
rw.AddResource("Author", "Chistian Nagel");
rw.AddResource("Publisher", "Wrox Press");
rw.Close();
}
//Here is how it should have been coded accoding to my understanding where
the instance ResXResourceWriter is
// implicitly using the dispose pattern
using(ResXResourceWriter rw = new ResXResourceWriter("Demo.resx"))
{
Image image = Image.FromFile("bell.gif");
rw.AddResource("Mylogo",image);
rw.AddResource("Title","Professional C#");
rw.AddResource("Chapter", "Localization");
rw.AddResource("Author", "Chistian Nagel");
rw.AddResource("Publisher", "Wrox Press");
}
//Tony
Here is some code and I suspect that this code is coded wrong because this
code doesn't make sense with how the using is used here. I suspect that it
should have been codes like see at the bottom.
Or is it something that I miss here saying that the way they use the using
here is perfectly correct and valid ?
The book I read say the following about the using. It says "The using
statement specifies that the image resources should be automatically
displosed at the end of the using block"
ResXResourceWriter rw = new ResXResourceWriter("Demo.resx");
using(Image image = Image.FromFile("bell.gif"))
{
rw.AddResource("Mylogo",image);
rw.AddResource("Title","Professional C#");
rw.AddResource("Chapter", "Localization");
rw.AddResource("Author", "Chistian Nagel");
rw.AddResource("Publisher", "Wrox Press");
rw.Close();
}
//Here is how it should have been coded accoding to my understanding where
the instance ResXResourceWriter is
// implicitly using the dispose pattern
using(ResXResourceWriter rw = new ResXResourceWriter("Demo.resx"))
{
Image image = Image.FromFile("bell.gif");
rw.AddResource("Mylogo",image);
rw.AddResource("Title","Professional C#");
rw.AddResource("Chapter", "Localization");
rw.AddResource("Author", "Chistian Nagel");
rw.AddResource("Publisher", "Wrox Press");
}
//Tony