本文整理汇总了C#中list类的典型用法代码示例。如果您正苦于以下问题:C# list类的具体用法?C# list怎么用?C# list使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
list类属于命名空间,在下文中一共展示了list类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: constantConverter
/// <summary>
/// 常量转换
/// </summary>
protected constantConverter()
{
list<keyValue<hashCode<Type>, func<object, string>>> values = new list<keyValue<hashCode<Type>, func<object, string>>>();
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool), convertConstantBoolTo01));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool?), convertConstantBoolNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte), convertConstantByte));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte?), convertConstantByteNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte), convertConstantSByte));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte?), convertConstantSByteNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short), convertConstantShort));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short?), convertConstantShortNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort), convertConstantUShort));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort?), convertConstantUShortNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int), convertConstantInt));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int?), convertConstantIntNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint), convertConstantUInt));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint?), convertConstantUIntNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long), convertConstantLong));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long?), convertConstantLongNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong), convertConstantULong));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong?), convertConstantULongNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float), convertConstantFloat));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float?), convertConstantFloatNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double), convertConstantDouble));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double?), convertConstantDoubleNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal), convertConstantDecimal));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal?), convertConstantDecimalNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime), convertConstantDateTimeMillisecond));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime?), convertConstantDateTimeMillisecondNullable));
values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(string), null));
converters = new staticDictionary<hashCode<Type>, func<object, string>>(values);
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:35,代码来源:constantConverter.cs
示例2: OnAfterUsingDirectiveParse
protected override void OnAfterUsingDirectiveParse(
Location location,
list<string> name,
list<Location> nameLocations,
string alias,
Location aliasLocation,
GlobalEnv beforeEnv,
GlobalEnv afterEnv
)
{
// do not notify Manager
}
开发者ID:vestild,项目名称:nemerle,代码行数:12,代码来源:HighlightingLexer.cs
示例3: OnAfterNamespaceParse
protected override void OnAfterNamespaceParse(
Location location,
list<string> name,
list<Location> nameLocations,
GlobalEnv outsideEnv,
GlobalEnv insideEnv,
Location headerLocation,
Location bodyOpenTokenLocation,
Location bodyCloseTokenLocation
)
{
// do not notify Manager
}
开发者ID:vestild,项目名称:nemerle,代码行数:13,代码来源:HighlightingLexer.cs
示例4: createHouse
public House createHouse(string housename, string password, int userID, string _addr, string _city, string _state)
{
using (var context = new houseMateEntities01())
{
if (!houseExists(housename))
{
if (getTID(userID) <= 0)
{
// create the new house
house newHouse = new house
{
houseName = housename,
password = password,
address = _addr,
city = _city,
state = _state
};
context.houses.Add(newHouse);
context.SaveChanges();
// create the list for that house
list newList = new list
{
FK_houseID = newHouse.PK_houseID
};
context.lists.Add(newList);
context.SaveChanges();
// create the notice board for that house
notice_board newNBoard = new notice_board
{
FK_houseID = newHouse.PK_houseID
};
context.notice_board.Add(newNBoard);
context.SaveChanges();
return joinHouse(housename, password, userID);
}
else
{
return new House(-1, "already in a house");
}
}
else
{
return new House(-1, "house doesn't exist");
}
}
}
开发者ID:RomeshPanditha,项目名称:House-Mate-Major-project-files,代码行数:49,代码来源:HouseDAL.cs
示例5: ToString
/// <summary>
/// 字符串
/// </summary>
/// <returns>字符串</returns>
public override string ToString()
{
if (toString == null)
{
list<string>.unsafer errorString = new list<string>(2).Unsafer;
if (Message != null) errorString.Add("附加信息 : " + Message);
if (StackFrame != null) errorString.Add("堆栈帧信息 : " + StackFrame.toString());
if (StackTrace != null) errorString.Add("堆栈信息 : " + StackTrace.ToString());
if (Exception != null) errorString.Add("异常信息 : " + Exception.ToString());
if (Type != exceptionType.None) errorString.Add("异常类型 : " + Type.ToString());
toString = errorString[0] + @"
" + errorString[1];
}
return toString;
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:19,代码来源:log.cs
示例6: Main
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Console.ReadLine();
Console.WriteLine("\nSoftware Engineering is fun!");
list<string> dayList = new list();
dayList.add("Tuesday");
dayList.add("Thursday");
Console.Write(dayList[0]);
Console.Write(" and ");
Console.write(dayList[1]);
Console.Writeline(" are the days I have CS2450.");
Console.WriteLine("Press the Enter key to continue...");
}
开发者ID:M-Freeze,项目名称:CS2450,代码行数:19,代码来源:HelloWorld.cs
示例7: Load
public bool Load()
{
try
{
Core.RecoverFile(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics", channel.Name);
if (File.Exists(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics"))
{
lock (data)
{
data = new List<list>();
XmlDocument stat = new XmlDocument();
stat.Load(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics");
if (stat.ChildNodes[0].ChildNodes.Count > 0)
{
foreach (XmlNode curr in stat.ChildNodes[0].ChildNodes)
{
list item = new list
{
user = curr.Attributes[0].Value,
messages = int.Parse(curr.Attributes[1].Value),
logging_since = DateTime.FromBinary(long.Parse(curr.Attributes[3].Value))
};
if (curr.Attributes.Count > 4)
{
item.URL = curr.Attributes[4].Value;
}
data.Add(item);
}
}
}
}
}
catch (Exception f)
{
Core.HandleException(f, "statistics");
}
return false;
}
开发者ID:benapetr,项目名称:wikimedia-bot,代码行数:38,代码来源:Statistics.cs
示例8: calculateTurnSequence
public list<Vector2>[] calculateTurnSequence(list<Vector2> movement1,list<Vector2> movement2)
{
list<Vector2>[] velocitySequences= new list<Vector2>[2];
for(int i=1; i<Math.Max(movement1.Count, movement2.Count); i++)
{
Vector2 vel1, vel2;
bool recheck=false;
if(i<movement1.Count) vel1=movement1[i]-movement1[i-1]; //If either player stops moving, add zero vectors to their velocity sequence
else vel1=Vector2.zero;
if(i<movement2.Count) vel2=movement2[i]-movement2[i-1];
else vel2=Vector2.zero;
if(boardManager.isOccupied(movement1[i])){
velocitySequences[0][i]=0-vel1;
recheck=true;
} //If collides with obstacle, reverse velocity vector
else velocitySequences[0][i]=vel1;
if(boardManager.isOccupied(movement2[i])){
velocitySequences[1][i]=0-vel2;
recheck=true;
}
else velocitySequences[1][i]=vel2;
movement1[i]=movement1[i-1]+vel1; //update position vectors according to velocity vector
movement2[i]=movement2[i-1]+vel2;
if(movement1[i]==movement2[i]){ //If collides with other player, swap velocity vector
Vector2 temp=velocitySequences[0][i];
velocitySequences[0][i]=velocitySequences[1][i];
velocitySequences[1][i]=temp;
recheck=true;
}
movement1[i]=movement1[i-1]+vel1; //update position vectors according to velocity vector
movement2[i]=movement2[i-1]+vel2; //how should the remaining movement positions be updated?
if(recheck) i--; //rechecks for collisions if changes were made
}
return velocitySequences;
}
开发者ID:GCSShatteredSpace,项目名称:New-scripts,代码行数:38,代码来源:turnManager.cs
示例9: Stat
public void Stat(string nick, string message, string host)
{
if (Module.GetConfig(channel, "Statistics.Enabled", false))
{
list user = null;
lock (data)
{
foreach (list item in data)
{
if (nick.ToUpper() == item.user.ToUpper())
{
user = item;
break;
}
}
}
if (user == null)
{
user = new list();
user.user = nick;
user.logging_since = DateTime.Now;
lock (data)
{
data.Add(user);
}
}
user.URL = core.Host.Host2Name(host);
user.messages++;
Module.SetConfig(channel, "HTML.Update", true);
changed = true;
Stored = false;
}
}
开发者ID:atdt,项目名称:wikimedia-bot,代码行数:33,代码来源:Statistics.cs
示例10: AssertEquals
AssertEquals(list.array[0].version, Version.ONE);
开发者ID:ngallagher,项目名称:simplexml,代码行数:1,代码来源:TextTest.cs
示例11: filterNode
/// <summary>
/// 子孙节点筛选
/// </summary>
/// <param name="path">筛选器</param>
/// <param name="value">筛选节点集合</param>
/// <returns>匹配的HTML节点集合</returns>
private static keyValue<list<htmlNode>, bool> filterNode(filter path, keyValue<list<htmlNode>, bool> value)
{
list<nodeIndex> values = new list<nodeIndex>();
nodeIndex index = new nodeIndex { Values = value.Key.getList() };
if (index.Values.Count != 0)
{
if (value.Value)
{
HashSet<htmlNode> newValues = new HashSet<htmlNode>(), historyNodes = new HashSet<htmlNode>();
if (path.values == null)
{
if (path.value != null)
{
string tagName = path.value;
while (true)
{
if (index.Values == null)
{
if (values.Count == 0) break;
else index = values.Pop();
}
htmlNode node = index.Values[index.Index];
if (node.TagName == tagName) newValues.Add(node);
if (node.children.count() == 0 || historyNodes.Contains(node))
{
if (++index.Index == index.Values.Count) index.Values = null;
}
else
{
if (++index.Index != index.Values.Count) values.Add(index);
historyNodes.Add(node);
index.Values = node.children;
index.Index = 0;
}
}
}
else
{
while (true)
{
if (index.Values == null)
{
if (values.Count == 0) break;
else index = values.Pop();
}
htmlNode node = index.Values[index.Index];
newValues.Add(node);
if (node.children.count() == 0 || historyNodes.Contains(node))
{
if (++index.Index == index.Values.Count) index.Values = null;
}
else
{
if (++index.Index != index.Values.Count) values.Add(index);
historyNodes.Add(node);
index.Values = node.children;
index.Index = 0;
}
}
}
}
else
{
staticHashSet<string> tagNames = path.values;
while (true)
{
if (index.Values == null)
{
if (values.Count == 0) break;
else index = values.Pop();
}
htmlNode node = index.Values[index.Index];
if (tagNames.Contains(node.TagName)) newValues.Add(node);
if (node.children.count() == 0 || historyNodes.Contains(node))
{
if (++index.Index == index.Values.Count) index.Values = null;
}
else
{
if (++index.Index != index.Values.Count) values.Add(index);
historyNodes.Add(node);
index.Values = node.children;
index.Index = 0;
}
}
}
if (newValues.Count != 0)
{
return new keyValue<list<htmlNode>, bool>(new list<htmlNode>(newValues), newValues.Count > 1);
}
}
else
{
list<htmlNode> newValues = new list<htmlNode>();
//.........这里部分代码省略.........
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:101,代码来源:htmlNode.cs
示例12: ToDoubleList
public static list ToDoubleList(list src)
{
list ret = new list();
double entry;
for (int i = 0; i < src.Data.Length - 1; i++)
{
if (double.TryParse(src.Data[i].ToString(), out entry))
{
ret.Add(entry);
}
}
return ret;
}
开发者ID:ChrisD,项目名称:opensim,代码行数:13,代码来源:LSL_Types.cs
示例13: Html
/// <summary>
/// 生成HTML
/// </summary>
/// <param name="isTag">是否包含当前标签</param>
/// <returns>HTML</returns>
public string Html(bool isTag)
{
if (TagName != null)
{
if (web.html.NonanalyticTagNames.Contains(TagName))
{
if (isTag && TagName.Length != 1)
{
using (charStream strings = new charStream())
{
tagHtml(strings);
strings.Write(nodeText.Html);
tagRound(strings);
return strings.ToString();
}
}
}
else
{
using (charStream strings = new charStream())
{
if (isTag) tagHtml(strings);
if (children.count() != 0)
{
htmlNode node;
list<nodeIndex> values = new list<nodeIndex>();
nodeIndex index = new nodeIndex { Values = children };
while (true)
{
if (index.Values == null)
{
if (values.Count == 0) break;
{
index = values.Pop();
index.Values[index.Index].tagRound(strings);
if (++index.Index == index.Values.Count)
{
index.Values = null;
continue;
}
}
}
node = index.Values[index.Index];
string nodeTagName = node.TagName;
bool isNonanalyticTagNames = nodeTagName != null && web.html.NonanalyticTagNames.Contains(nodeTagName);
if (node.children.count() == 0 || nodeTagName == null || isNonanalyticTagNames)
{
if (nodeTagName != null && nodeTagName.Length != 1) node.tagHtml(strings);
strings.Write(node.nodeText.Html);
if (nodeTagName != null && nodeTagName.Length != 1) node.tagRound(strings);
if (++index.Index == index.Values.Count) index.Values = null;
}
else
{
node.tagHtml(strings);
values.Add(index);
index.Values = node.children;
index.Index = 0;
}
}
}
if (isTag) tagRound(strings);
return strings.ToString();
}
}
}
return nodeText.Html;
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:73,代码来源:htmlNode.cs
示例14: ToDoubleList
public static list ToDoubleList(list src)
{
list ret = new list();
double entry;
for (int i = 0; i < src.Data.Length - 1; i++)
{
if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry))
{
ret.Add(entry);
}
}
return ret;
}
开发者ID:Gnu32,项目名称:Silverfin,代码行数:13,代码来源:LSL_Types.cs
示例15: Get
/// <summary>
/// 根据筛选路径值匹配HTML节点集合
/// </summary>
/// <param name="path">筛选路径</param>
/// <param name="node">筛选节点</param>
/// <returns>匹配的HTML节点集合</returns>
public static list<htmlNode> Get(string path, htmlNode node)
{
if (path != null && path.Length != 0)
{
list<htmlNode> nodes = new list<htmlNode>();
nodes.Add(node);
return get(path).get(new keyValue<list<htmlNode>, bool>(nodes, false));
}
return null;
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:16,代码来源:htmlNode.cs
示例16: output
/// <summary>
/// 日志信息写文件
/// </summary>
private void output()
{
while (!isStop)
{
Monitor.Enter(logLock);
try
{
if (newDebugs.Count == 0) Monitor.Wait(logLock);
list<debug> oldDebugs = currentDebugs;
currentDebugs = newDebugs;
newDebugs = oldDebugs;
}
finally { Monitor.Exit(logLock); }
output(string.Join(@"
- - - - - - - - - -
", currentDebugs.GetArray(error => error.ToString())));
currentDebugs.Empty();
}
newDebugs = null;
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:23,代码来源:log.cs
示例17: AssertEquals
AssertEquals(list.Get(0).version, Version.ONE);
开发者ID:ngallagher,项目名称:simplexml,代码行数:1,代码来源:ScatterTest.cs
示例18: convertFromList
private Composition convertFromList(list l)
{
Composition result = new Composition();
if (l.property != null)
{
foreach (property p in l.property)
{
result.put(p.name, p.Value);
}
}
if (l.list1 != null)
{
foreach (list l1 in l.list1)
{
result.properties.Add(l1.name, convertFromList(l1));
}
}
return result;
}
开发者ID:ihtims,项目名称:lmBoxClient-csharp,代码行数:19,代码来源:ValidationResult.cs
示例19: clear
/// <summary>
/// 清除表单数据
/// </summary>
/// <param name="values">表单数据集合</param>
private static void clear(list<value> values)
{
int count = values.Count;
if (count != 0)
{
value[] formArray = values.array;
for (int index = 0; index != count; ++index) formArray[index].Clear();
values.Empty();
}
}
开发者ID:JosephGeeker,项目名称:TonyFramework,代码行数:14,代码来源:RequestFormPlus.cs
示例20: ReplaceChild
/// <summary>
/// 替换子节点
/// </summary>
/// <param name="oldNode">待替换的子节点</param>
/// <param name="newNode">新的子节点</param>
/// <returns>是否存在待替换的子节点</returns>
public bool ReplaceChild(htmlNode oldNode, htmlNode newNode)
{
bool isReplace = false;
if (oldNode != null && newNode != null)
{
int oldIndex = this[oldNode];
if (oldIndex != -1)
{
if (newNode.TagName == string.Empty)
{
oldNode.Parent = null;
if (newNode.children == null) children.RemoveAt(oldIndex);
else
{
foreach (htmlNode value in newNode.children) value.Parent = this;
if (newNode.children.Count == 1) children[oldIndex] = newNode.children[0];
else if (oldIndex == children.Count - 1)
{
children.RemoveAt(oldIndex);
children.Add(newNode.children);
}
else
{
list<htmlNode>.unsafer values = new list<htmlNode>(children.Count + newNode.children.Count).Unsafer;
int newIndex = 0;
while (newIndex != oldIndex) values.Add(children[newIndex++]);
values.List.Add(newNode.children);
for (oldIndex = children.Count; ++newIndex != oldIndex; values.Add(children[newIndex])) ;
children = values.List;
}
}
newNode.children = null;
isReplace = true;
}
else if (!newNode.IsNode(this))
{
int newIndex = this[newNode];
if (newIndex == -1)
{
if (newNode.Parent != null) newNode.Parent.RemoveChild(newNode);
newNode.Parent = this;
children[oldIndex] = newNode;
oldNode.Parent = null;
}
else
{
children[oldIndex] = newNode;
oldNode.Parent = null;
children.RemoveAt(newIndex);
}
isReplace = true;
}
}
}
return isReplace;
}
开发者ID:khaliyo,项目名称:fastCSharp,代码行数:62,代码来源:htmlNode.cs
注:本文中的list类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论