本文整理汇总了C#中List.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# List.GetType方法的具体用法?C# List.GetType怎么用?C# List.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: databinding
private void databinding(List<RFDeviceAPP.Common.NSPRFIQ01.Response.UtilityHeader> list)
{
this.dataGridTableStyle1.MappingName = list.GetType().Name;
this.dataGrid1.TableStyles.Clear();
this.dataGrid1.TableStyles.Add(this.dataGridTableStyle1);
this.dataGrid1.DataSource = list;
}
示例2: SaveGuitars
public void SaveGuitars(List<Guitar> guitars)
{
var serializer = new XmlSerializer(guitars.GetType());
TextWriter tw = new StreamWriter(Path);
serializer.Serialize(tw, guitars);
tw.Close();
}
示例3: Main
static void Main(string[] args)
{
Type guyType = typeof(Guy);
Console.WriteLine("{0} extends {1}",
guyType.FullName,
guyType.BaseType.FullName);
// output: TypeExamples.Guy extends System.Object
Type nestedClassType = typeof(NestedClass.DoubleNestedClass);
Console.WriteLine(nestedClassType.FullName);
// output: TypeExamples.Program+NestedClass+DoubleNestedClass
List<Guy> guyList = new List<Guy>();
Console.WriteLine(guyList.GetType().Name);
// output: List`1
Dictionary<string, Guy> guyDictionary = new Dictionary<string, Guy>();
Console.WriteLine(guyDictionary.GetType().Name);
// output: Dictionary`2
Type t = typeof(Program);
Console.WriteLine(t.FullName);
// output: TypeExamples.Program
Type intType = typeof(int);
Type int32Type = typeof(Int32);
Console.WriteLine("{0} - {1}", intType.FullName, int32Type.FullName);
// System.Int32 - System.Int32
Console.WriteLine("{0} {1}", float.MinValue, float.MaxValue);
// output:-3.402823E+38 3.402823E+38
Console.WriteLine("{0} {1}", int.MinValue, int.MaxValue);
// output:-2147483648 2147483647
Console.WriteLine("{0} {1}", DateTime.MinValue, DateTime.MaxValue);
// output: 1/1/0001 12:00:00 AM 12/31/9999 11:59:59 PM
Console.WriteLine(12345.GetType().FullName);
// output: System.Int32
Console.ReadKey();
}
示例4: Main
public static void Main (string[] args) {
var coll = new List<int>() { 5, 25, 50, 125 };
var arr = coll.ToArray();
Console.WriteLine("{0} {1}", coll.GetType(), arr.GetType());
Console.WriteLine("{0} {1}", coll[0].GetType(), arr[0].GetType());
}
示例5: DisplayAllWord
public static void DisplayAllWord(List<string> ls)
{
Type t = ls.GetType();
Console.WriteLine("list of {0} contein", t.Name);
foreach (string s in ls)
Console.WriteLine(s);
}
示例6: Form1_Load
private void Form1_Load(object sender, EventArgs e)
{
if (ItemsFile.Exists)
{
List<ItemInfo> lst = new List<ItemInfo>();
XmlSerializer xml = new XmlSerializer(lst.GetType());
using (Stream s = ItemsFile.OpenRead())
{
lst = xml.Deserialize(s) as List<ItemInfo>;
}
foreach (ItemInfo item in lst)
{
CalendarItem cal = new CalendarItem(calendar1, item.StartTime, item.EndTime, item.Text);
if (!(item.R == 0 && item.G == 0 && item.B == 0))
{
cal.ApplyColor(Color.FromArgb(item.A, item.R, item.G, item.B));
}
_items.Add(cal);
}
PlaceItems();
}
}
示例7: ReadData
public List<CombinerModel> ReadData(string fileName)
{
List<CombinerModel> list = new List<CombinerModel>();
object obj = CacheHelper.ReadData(ConstMember.CONFIG_CACHE_ID);
if (obj == null)
{
string strFilePath = GetAbsolutPath(fileName);
try
{
obj = XMLHelper.LoadFromXml(strFilePath, list.GetType());
CacheDependency dep = new CacheDependency(strFilePath);
CacheHelper.WriteData(ConstMember.CONFIG_CACHE_ID, dep, obj);
}
catch
{
}
}
if (obj != null && obj is List<CombinerModel>)
{
list = obj as List<CombinerModel>;
}
return list;
}
示例8: FtpUserStore
static FtpUserStore()
{
_users = new List<FtpUser>();
XmlSerializer serializer = new XmlSerializer(_users.GetType(), new XmlRootAttribute("Users"));
if (File.Exists("users.xml"))
{
_users = serializer.Deserialize(new StreamReader("users.xml")) as List<FtpUser>;
}
else
{
_users.Add(new FtpUser
{
UserName = "rick",
Password = "test",
HomeDir = "C:\\Utils"
});
using (StreamWriter w = new StreamWriter("users.xml"))
{
serializer.Serialize(w, _users);
}
}
}
示例9: GetCourses
public Course[] GetCourses()
{
List<Course> holder = new List<Course>();
Console.Write(holder.GetType());
using (SqlConnection conn = new SqlConnection())
{
// Create the connectionString
// Trusted_Connection is used to denote the connection uses Windows Authentication
conn.ConnectionString = "Data Source=tfs;Initial Catalog=study3;Integrated Security=True";
conn.Open();
// Create the command
SqlCommand command = new SqlCommand("SELECT * FROM db_owner.course", conn);
//// Add the parameters.
//command.Parameters.Add(new SqlParameter("0", 1));
// Use a SqlDataReader to read the results from the SqlCommand
using (SqlDataReader reader = command.ExecuteReader())
{
foreach (IDataRecord record in reader)
{
string[] dataRow = ReadSingleRow((IDataRecord)reader);
//Course courseHolder = new Course(dataRow);
//holder.Add(courseHolder);
}
}
}
Course[] returnCourseArray = holder.ToArray();
return returnCourseArray;
}
示例10: CreateSampleQueries
private static void CreateSampleQueries()
{
var queries = new List<Query>
{
new Query
{
OrderBy = "Id",
OutputFileName = "Result0.xml",
WhereClauses = new List<WhereClause>
{
new WhereClause
{
PropertyName = "City",
Type = "Equals",
Value = "Sofia"
},
new WhereClause
{
PropertyName = "Year",
Type = "GreaterThan",
Value = "1999"
}
}
}
};
var serializer = new XmlSerializer(queries.GetType(), new XmlRootAttribute("Queries"));
using (var fs = new FileStream("Queries.xml", FileMode.Create))
{
serializer.Serialize(fs, queries);
}
}
示例11: Main
static void Main(string[] args)
{
// Use var for an array.
// Note the use of the new implicitly typed array syntax.
// The compiler looks at the initialization list and infers that the
// array type you want is int[].
var numbers = new[] { 1, 2, 3 };
Console.WriteLine("Array initializer: ");
foreach (int n in numbers)
{
Console.WriteLine(n.ToString());
}
// This writes "System.Int32[]".
Console.WriteLine(numbers.GetType().ToString());
Console.WriteLine();
// Use var for a generic list type.
// Note the use of the new collection initializer syntax, too.
var names = new List<string> { "Chuck", "Bob", "Steve", "Mike" };
Console.WriteLine("List of names: ");
foreach (string s in names)
{
Console.WriteLine(s);
}
// This writes "System.Collections.Generic.List`1[System.String]".
// Note that the compiler calls any List<T> a List`1.
// To look up List<T> in the documentation, specify "List<T>".
Console.WriteLine(names.GetType().ToString());
Console.WriteLine();
// Wait for user to acknowledge results.
Console.WriteLine("Press Enter to terminate...");
Console.Read();
}
示例12: Load
/// <summary>
/// 通过文件名获取配置
/// </summary>
/// <param name="fileName">配置文件名不带后缀的</param>
/// <returns></returns>
public static List<VarItem> Load(string fileName) {
//如果缓存里面有这个配置就直接返还
if (dataCache.ContainsKey(fileName)&& dataCache[fileName] != null)
return dataCache[fileName];
//如果缓存里没这个配置就第一次读取
string path = GetDefaultConfigPath(fileName);
//校验是路径是否有效
if (File.Exists(path) == false)
throw new FileNotFoundException("文件没找到", path);
//读取
List<VarItem> items = new List<VarItem>();
XmlSerializer xmlSerializer = new XmlSerializer(items.GetType());
FileStream fs = new FileStream(path, FileMode.Open);
using (fs) {
try {
items = xmlSerializer.Deserialize(fs) as List<VarItem>;
}
catch (InvalidOperationException ex) {
throw ;
}
}
//如果配置没有内容可能会读到空的items,不过这是允许的。
dataCache.Add(fileName, items);
return items;
}
示例13: LogNameDisplaysReadablyGenerics
public void LogNameDisplaysReadablyGenerics()
{
var subject = new List<int>();
var logger = new Log4NetLogger(subject.GetType());
logger.Name.Should().Be("List<Int32>");
}
示例14: MACalculator
/// <summary>
/// MA: moving average
/// An often used helper method which take in a list of values (of consecutive
/// days) and calculates the moving average
/// </summary>
/// <param name="values">a list of certain length of values of different dates</param>
/// <returns>MA</returns>
public static double[] MACalculator(List<double> values)
{
double[] resultArray = new double[6];
double sum = 0.0;
int days = 0;
if (values.Count >= 250)
{
for (int i = 0; i <= 249; i++)
{
sum += values[i];
if (values.GetType().Name != "DBNull")
days++;
if (i == 4) resultArray[0] = sum / days;
else if (i == 9) resultArray[1] = sum / days;
else if (i == 19) resultArray[2] = sum / days;
else if (i == 59) resultArray[3] = sum / days;
else if (i == 119) resultArray[4] = sum / days;
else if (i == 249) resultArray[5] = sum / days;
}
}
else
{
Console.WriteLine("data not available, needs to wait for 250 days");
}
return resultArray;
}
示例15: SaveAmplifiers
public void SaveAmplifiers(List<Amplifier> amplifiers)
{
var serializer = new XmlSerializer(amplifiers.GetType());
TextWriter tw = new StreamWriter(@"d:\guitarweb\amplifiers.xml");
serializer.Serialize(tw, amplifiers);
tw.Close();
}