开发者

Accessing a Static Method in C#

I have this class:

public static class CsvWriter
    {
       private static StreamWriter _writer = new StreamWriter(@"c:\temp\ssis_list.csv");

       public static  StreamWriter Writer 
       {
          get { return _writer; }
开发者_开发百科       }
    }

This is being called from another class

 class Program
  {
     ...
     static void GetConnections(string path,string pkgname,string server)
        {

          _writer.WriteLine(myLine);
        }
   }

Which has this error

The name '_writer' does not exist in the current context    

How can I fix this?


You want CsvWriter.Writer.WriteLine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜