Live Chat Icon For mobile
Live Chat Icon

Is there any easy way to convert VB.NET code to C#?

Platform: WinForms| Category: Tips

If you add a BMP file to your solution using the File|Add Existing Item… Menu Item, then change the Build Action property of this BMP file to Embedded Resource, you can then access this resource with code similar to:

	
	// WindowsApplication6 corresponds to Default Namespace in your project settings.
	// subfolders should be the folder names if any, inside which the bmp is added. If the bmp was added to the top level, you don’t have to specify anything here.
	string bmpName = 'WindowsApplication6.subfolders.sync.bmp';  
	System.IO.Stream strm = null;
	try
	{
		strm = this.GetType().Assembly.GetManifestResourceStream(bmpName);
		pictureBox1.Image = new Bitmap(strm);
		// Do the same for Icons 
		// Icon icon1 = new Icon(strm);
	}
	catch(Exception e)
	{
		MessageBox.Show(e.Message);
	}
	finally
	{
		if(strm != null)
			strm.Close();
	}

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.