开发者

Accessing a Static Method in C#

开发者 https://www.devze.com 2022-12-08 22:14 出处:网络
I have this class: public static class CsvWriter { private static StreamWriter _writer = new StreamWriter(@\"c:\\temp\\ssis_list.csv\");

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

精彩评论

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