これが簡単な質問だといいのですが。私はC#で簡単なコンソールアプリケーションを構築しています。私はクラスを持っています:
using System;
using Filter;
public class Params
{
public string key;
public bool distinct;
public List<string> fields;
public string filter;
public int limit;
public int skip;
public bool total;
public List<Tuple<string, GroupType>> group;
public List<Tuple<string, OrderType>> order;
public Params()
{
key = "";
distinct = false;
fields = new List<string>();
filter = "";
group = new List<Tuple<string, GroupType>>();
limit = 0;
order = new List<Tuple<string, OrderType>>();
skip = 0;
total = false;
}
public void AddGroup(string field, GroupType type)
{
group.Add(new Tuple<string, GroupType>(field, type));
}
public void AddOrder(string field, OrderType type)
{
order.Add(new Tuple<string, OrderType>(field, type));
}
}
私のプログラムの.csクラスは次のとおりです。
namespace csharpExample
{
class Program
{
public static void Main(string[] args)
{
Params p = new Params();
Console.WriteLine("Test");
}
}
}
Main()が呼び出されるprogram.csクラスでParamsを使用したいと思います。上記のようにParamsを簡単に使用できると思いました。また、Paramsを使用してみました。ディレクティブが見つからないため、これらは両方ともVSのエラーです。また、独自の名前空間を追加してみました。namespaceMyNameSpace; 私のParamsクラスの周り。これを行っても、MyNameSpaceを使用することはできません。それが見つからないのでステートメント。
たくさんの関数を、再利用できるクラスに抽出したいだけです。作成したこのクラスを呼び出すにはどうすればよいですか?
-助けてくれてありがとう。