title: Declaring a member of static type in c#
body: <p><strong>Update #2 - Mystery Solved</strong></p>
  
  <p>I have figure out the issue - it was my misunderstanding of the keyword <em>static</em> when being use in java inner classes.  I assumed that static meant static in the traditional sense - as with c#.  In the case of Java, static inner classes have a slightly different meaning.  I personally would have used a different keyword other than static to achieve the same effect to eliminate the confusion.  </p>
  
  <p>Here are a couple good links that explain what static inner classes mean in java. </p>
  
  <p><a href="http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html" rel="nofollow">link1</a>
  <a href="http://www.javaworld.com/javaworld/javaqa/1999-08/01-qa-static2.html?page=1" rel="nofollow">link2</a></p>
  
  <p>Sorry for sending everyone of a wild goose chase :)</p>
  
  <p><strong>Original Post</strong></p>
  
  <p>In java I can write the following:</p>
  
  <pre><code>public class UseStaticMembers {
      private Holder holder;
  
      holder.txt1 = "text";
      holder.txt2 = "text";
  
      CallSomeMethod(holder);
  }
  
  
  static class Holder {
      public string txt1;
      public string txt2;
  }
  </code></pre>
  
  <p>But I cannot do this in C#.  I get the following error: "Cannot declare a variable of static type 'Holder'" on the line: "private Holder holder;"</p>
  
  <p>How can I achieve the same effect in C# (if I can).</p>
  
  <p><strong>Update #1</strong></p>
  
  <p>Here is an example of how this pattern is used to optimize custom list adapters.  As you can see I can't just access the static member via the static class name but need to reference it via an variable.  It needs to be passed to the Tag.</p>
  
  <pre><code>public class WeatherAdapter extends ArrayAdapter&lt;Weather&gt;{
  
  Context context; 
  int layoutResourceId;    
  Weather data[] = null;
  
  public WeatherAdapter(Context context, int layoutResourceId, Weather[] data) {
      super(context, layoutResourceId, data);
      this.layoutResourceId = layoutResourceId;
      this.context = context;
      this.data = data;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      View row = convertView;
      WeatherHolder holder = null;
  
      if(row == null)
      {
          LayoutInflater inflater = ((Activity)context).getLayoutInflater();
          row = inflater.inflate(layoutResourceId, parent, false);
  
          holder = new WeatherHolder();
          holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
          holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
  
          row.setTag(holder);
      }
      else
      {
          holder = (WeatherHolder)row.getTag();
      }
  
      Weather weather = data[position];
      holder.txtTitle.setText(weather.title);
      holder.imgIcon.setImageResource(weather.icon);
  
      return row;
  }
  
  static class WeatherHolder
  {
      ImageView imgIcon;
      TextView txtTitle;
  }
  </code></pre>
  
  <p>}</p>