After I made a public static class has some public static variables when I tried to use one of static variables VS had an exception The type initializer for 'EM_Image.staticvariables' threw an exception.
Why? and how I can solve it?
public static class StaticVariables
{
public static string image_source = "ahmed";
public static Bitmap b = new Bitmap(image_source);
public static int K_numcolors = 0;
public static int M_leastbits = 0;
public static BitmapImage bi = null;
public static Color[,] RGB_num = new Color[b.Width, b.Height]; // orginal colors
public static Color[,] new_RGB_byte = new Color[b.Width, b.Height]; // colors after compression 1
public static string[,,] RGB_Bits = new string[b.Width, b.Height, 3]; // original images
public static string[,,] new1_RGB_Bits = new string[b.Width, b.Height, 3]; // after compression 1
}
private void bt_Browse_Click(object sender, System.Windows.RoutedEventArgs e)
{
browse.ShowDialog();
direction_text.Text = browse.FileName;
staticvariables.image_source = browse.FileName;
ImageSource imageSource = new BitmapImage(new Uri(browse.FileName));
pic_origin.Source = imageSource;
}
C#instead ofC.