本文整理汇总了C#中List.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# List.Remove方法的具体用法?C# List.Remove怎么用?C# List.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
int withoutPenCount = 0;
string lineReader = Console.ReadLine(); // In this implementation of program, the first line of input doesn't matter
//string[] tokens = lineReader.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
lineReader = Console.ReadLine(); // Students without pen
string[] withoutPen = lineReader.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
lineReader = Console.ReadLine(); // Students with pen
// Use List<string>, because it is easier to remove directly element by value
List<string> withPen = new List<string>(lineReader.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
for (int i = 0; i < withoutPen.Length; i++)
{
string left = (int.Parse(withoutPen[i]) - 1).ToString();
string right = (int.Parse(withoutPen[i]) + 1).ToString();
if (withPen.Contains(left))
{
withPen.Remove(left);
}
else if (withPen.Contains(right))
{
withPen.Remove(right);
}
else
{
withoutPenCount++;
}
}
Console.WriteLine(withoutPenCount);
}
示例2: UpdateImports
public void UpdateImports(SolutionEntityItem item, List<String> imports)
{
// Remove imports
imports.Remove (importCocoaApplication);
imports.Remove (importConsoleApplication);
imports.Remove (importCocoaLibrary);
// Check project nature
MonobjcProject project = item as MonobjcProject;
if (project == null) {
return;
}
switch (project.ApplicationType) {
case MonobjcProjectType.CocoaApplication:
imports.Add (importCocoaApplication);
break;
case MonobjcProjectType.ConsoleApplication:
imports.Add (importConsoleApplication);
break;
case MonobjcProjectType.CocoaLibrary:
imports.Add (importCocoaLibrary);
break;
}
}
示例3: Find
public List<List<KingsburgDie>> Find( int targetSum, DiceCollection bag )
{
//DiceCollection clone = (DiceCollection)bag.Clone();
DiceCollection clone = bag;
List<KingsburgDie> elements = (List<KingsburgDie>)clone;
mResults = new List<List<KingsburgDie>>();
RecursiveFind( targetSum, 0, new List<KingsburgDie>(), elements, 0 );
List<List<KingsburgDie>> copy = new List<List<KingsburgDie>>( mResults );
foreach( List<KingsburgDie> list in copy )
{
if( list.Count == 1 )
{
if( list[0].Type != KingsburgDie.DieTypes.Regular )
{
mResults.Remove( list );
}
}
IEnumerable<KingsburgDie> linq = from r in list
where r.Type == KingsburgDie.DieTypes.MarketNegative || r.Type == KingsburgDie.DieTypes.MarketPositive
select r;
List<KingsburgDie> marketDice = new List<KingsburgDie>( linq );
if( marketDice.Count > 1 )
{
mResults.Remove( list );
}
}
return mResults;
}
示例4: Optimize
public static List<FortData> Optimize(FortData[] pokeStops, LatLong latlng, GMapOverlay routeOverlay)
{
List<FortData> optimizedRoute = new List<FortData>(pokeStops);
// NN
FortData NN = FindNN(optimizedRoute, latlng.Latitude, latlng.Longitude);
optimizedRoute.Remove(NN);
optimizedRoute.Insert(0, NN);
for (int i = 1; i < pokeStops.Length; i++)
{
NN = FindNN(optimizedRoute.Skip(i), NN.Latitude, NN.Longitude);
optimizedRoute.Remove(NN);
optimizedRoute.Insert(i, NN);
Visualize(optimizedRoute, routeOverlay);
}
// 2-Opt
bool isOptimized;
do
{
optimizedRoute = Optimize2Opt(optimizedRoute, out isOptimized);
Visualize(optimizedRoute, routeOverlay);
}
while (isOptimized);
return optimizedRoute;
}
示例5: getConnectedBlockFrom
/// <summary>
/// Gets the connected blocks from the children blocks.
/// </summary>
/// <returns>List of the connected blocks.</returns>
/// <param name="children">List of the total blocks.</param>
/// <param name="root">Root block of the connected blocks.</param>
List<Transform> getConnectedBlockFrom(List<Transform> children, Transform root = null)
{
List<Transform> result = new List<Transform> ();
if (root == null) {
root = children[0];
}
children.Remove (root);
result.Add (root);
List<Transform> neighbors = getNeighbors (root, children);
foreach (Transform neighbor in neighbors) {
children.Remove(neighbor);
result.Add(neighbor);
}
List<List<Transform>> recursiveResults = new List<List<Transform>> ();
foreach (Transform neighbor in neighbors) {
recursiveResults.Add(getConnectedBlockFrom(children, neighbor));
}
foreach (List<Transform> recursiveResult in recursiveResults) {
result.AddRange(recursiveResult);
}
return result;
}
示例6: Main
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://sam2012"))
{
using (SPWeb web = site.OpenWeb())
{
//Test1(web);
// GetAllItemsIncludeFolders(web);
Test2(web);
}
Console.ReadKey();
}
List<string> l = new List<string>(){"1","2","3","4"};
for (int i = 0; i < 3; i++)
{
string s = l.FirstOrDefault(k => k == 1.ToString());
l.Remove(s);
string s1 = l.FirstOrDefault(k => k == 2.ToString());
l.Remove(s1);
}
foreach (string v in l)
{
Console.WriteLine(v);
}
Console.ReadKey();
}
示例7: MenuItemGPGSExportUIPackage
public static void MenuItemGPGSExportUIPackage()
{
List<string> exportList = new List<string>();
Debug.Log("Exporting plugin.");
AddToList(exportList, "Assets/GooglePlayGames");
AddToList(exportList, "Assets/Plugins/Android/libs");
AddToList(exportList, "Assets/Plugins/Android/MainLibProj");
AddToList(exportList, "Assets/Plugins/iOS");
exportList.Remove("Assets/GooglePlayGames/Editor/projsettings.txt");
exportList.Remove("Assets/GooglePlayGames/Editor/GPGSExportPackageUI.cs");
exportList.Remove("Assets/Plugins/Android/MainLibProj/AndroidManifest.xml");
string fileList = "Final list of files to export (click for details)\n\n";
foreach (string s in exportList) {
fileList += "+ " + s + "\n";
}
Debug.Log(fileList);
string path = EditorUtility.SaveFilePanel("Save plugin to", "",
"GooglePlayGamesPlugin-" + GooglePlayGames.PluginVersion.VersionString +
".unitypackage", "unitypackage");
if (path == null || path.Trim().Length == 0) {
Debug.LogWarning("Cancelled plugin export.");
return;
}
Debug.Log("Exporting plugin to " + path);
File.Delete(path);
AssetDatabase.ExportPackage(exportList.ToArray(), path);
EditorUtility.DisplayDialog("Export finished", "Plugin exported to " + path, "OK");
}
示例8: Merge
private static List<int> Merge(List<int> left, List<int> right)
{
List<int> result = new List<int>();
while(left.Count > 0 || right.Count>0)
{
if (left.Count > 0 && right.Count > 0)
{
if (left.First() <= right.First()) //Comparing First two elements to see which is smaller
{
result.Add(left.First());
left.Remove(left.First()); //Rest of the list minus the first element
}
else
{
result.Add(right.First());
right.Remove(right.First());
}
}
else if(left.Count>0)
{
result.Add(left.First());
left.Remove(left.First());
}
else if (right.Count > 0)
{
result.Add(right.First());
right.Remove(right.First());
}
}
return result;
}
示例9: Matches
public bool Matches(object one, object two)
{
var expected = new List<object>(one.As<IEnumerable>().OfType<object>());
var actual = new List<object>(two.As<IEnumerable>().OfType<object>());
foreach (object o in actual.ToArray())
{
if (expected.Contains(o))
{
actual.Remove(o);
expected.Remove(o);
}
}
foreach (object o in expected.ToArray())
{
if (actual.Contains(o))
{
actual.Remove(o);
expected.Remove(o);
}
}
return actual.Count == 0 && expected.Count == 0;
}
示例10: GetFilterFields
public static List<TableField> GetFilterFields(bool isB2B)
{
List<TableField> filterFields = new List<TableField>();
if (isB2B)
{
filterFields.AddRange(GetTableFields(m_B2BMastersTableName));
filterFields.AddRange(GetTableFields(m_B2BContactsTableName));
var temp = filterFields.FirstOrDefault(p => p.TableName.ToLower() == m_B2BContactsTableName.ToLower() && p.FieldName.ToLower() == "公司名称");
if (temp != null)
filterFields.Remove(temp);
}
else
{
filterFields.AddRange(GetTableFields(m_B2CMastersTableName));
}
for (int i = filterFields.Count - 1; i >= 0; i--)
{
if (filterFields[i].FieldName.ToLower().IsIn("id", "indate", "lasteditdate"))
{
filterFields.Remove(filterFields[i]);
}
}
return filterFields;
}
示例11: getClosestPosition
Vector3 getClosestPosition(ref List<GameObject> listObject)
{
GameObject closest = listObject[0];
if(listObject.Count==1){
if(closest!=null){ // permet d'éviter de le retourner si le jouerur meurt entre temps
return closest.transform.position;
}
else{
listObject.Remove(closest);
}
return Vector3.zero;
}
else{
if(closest!=null){
float distanceMin = Vector3.Distance(transform.position,closest.transform.position);
for (int i = 1; i < listObject.Count; i++){
if(listObject[i]!= null){
float distance = Vector3.Distance(transform.position, listObject[i].transform.position);
if(distance <= distanceMin){
distanceMin=distance;
closest = listObject[i];
}
}
else{
listObject.Remove(listObject[i]);
return transform.position;
}
}
return closest.transform.position;
}
}
return transform.position;
}
示例12: ReadDialog
/// <summary>
/// Constructor for Read dialog
/// </summary>
public ReadDialog(Epi.Windows.MakeView.Forms.MakeViewMainForm frm)
: base(frm)
{
InitializeComponent();
Construct();
SourceProjectNames = new Hashtable();
if (frm.projectExplorer != null)
{
if (frm.projectExplorer.currentPage != null)
{
this.sourceProject = frm.projectExplorer.currentPage.view.Project;
this.selectedProject = this.sourceProject;
this.selectedDataSource = this.selectedProject;
//--EI-48
//Adds datatable names to viewlist to enable other tables in project
List<string> SourceViewnames = this.sourceProject.GetViewNames();
SourceNonViewnames = this.sourceProject.GetNonViewTableNames();
foreach(string str in SourceViewnames)
{
View MView = this.sourceProject.GetViewByName(str);
DataTable ViewPages = MView.GetMetadata().GetPagesForView(MView.Id);
foreach(DataRow dt in ViewPages.Rows)
{
string ViewdataTable = MView.TableName + dt[ColumnNames.PAGE_ID];
Sourcedatatables.Add(ViewdataTable);
}
if (SourceNonViewnames.Contains(str)) { SourceNonViewnames.Remove(str); }
}
foreach(string str in Sourcedatatables)
{
SourceViewnames.Add(str);
if (SourceNonViewnames.Contains(str)) { SourceNonViewnames.Remove(str);}
}
//--
foreach (string s in this.sourceProject.GetNonViewTableNames())
{
string key = s.ToUpper().Trim();
if (!SourceProjectNames.Contains(key))
{
if (SourceViewnames.Contains(s))
{
SourceProjectNames.Add(key, true);
}
}
}
foreach (string s in this.sourceProject.GetViewNames())
{
string key = s.ToUpper().Trim();
if (!SourceProjectNames.Contains(key))
{
SourceProjectNames.Add(key, true);
}
}
}
}
}
示例13: Initialize
internal static void Initialize(CompositionContainer composition)
{
List<Language> languages = new List<Language>();
if (composition != null)
languages.AddRange(composition.GetExportedValues<Language>());
else {
languages.Add(new CSharpLanguage());
languages.Add(new VB.VBLanguage());
}
// Fix order: C#, VB, IL
var langs2 = new List<Language>();
var lang = languages.FirstOrDefault(a => a is CSharpLanguage);
if (lang != null) {
languages.Remove(lang);
langs2.Add(lang);
}
lang = languages.FirstOrDefault(a => a is VB.VBLanguage);
if (lang != null) {
languages.Remove(lang);
langs2.Add(lang);
}
langs2.Add(new ILLanguage(true));
for (int i = 0; i < langs2.Count; i++)
languages.Insert(i, langs2[i]);
#if DEBUG
languages.AddRange(ILAstLanguage.GetDebugLanguages());
languages.AddRange(CSharpLanguage.GetDebugLanguages());
#endif
allLanguages = languages.AsReadOnly();
}
示例14: Merge
//методът използва два списъка (left, right), които слива в един сортиран списък
static List<int> Merge(List<int> left, List<int> right)
{
List<int> result = new List<int>(); //декларираме списъка, в който ще получим резултата от сливането и сортирането
while (left.Count > 0 || right.Count > 0) //докато има елементи в поне един от двата списъка
{
if (left.Count > 0 && right.Count > 0) //ако има елементи и в двата списъка
{
if (left[0] <= right[0]) //ако първият елемент от левия списък е по-малък или равен от/на първия елемент от десния списък
{
result.Add(left[0]); //постави по-малкия елемент от двата на първо място в сортирания списък
left.Remove(left[0]); //премахни по-малкия елемент от списъка, в който е бил досега
}
else
{
result.Add(right[0]); //постави по-малкия елемент от двата на първо място в сортирания списък
right.Remove(right[0]); //премахни по-малкия елемент от списъка, в който е бил досега
}
}
else if (left.Count > 0) //ако първият списък има елементи
{
result.Add(left[0]); //постави най-левият елемент от този списък на първо място в сортирания списък
left.Remove(left[0]); //премахни елемента от списъка, в който е бил досега
}
else if (right.Count > 0) //ако вторият списък има елементи
{
result.Add(right[0]); //постави най-левият елемент от този списък на първо място в сортирания списък
right.Remove(right[0]); //премахни елемента от списъка, в който е бил досега
}
}
return result; //върни като резултат сортирания слят списък
}
示例15: PreFilter
public override IEnumerable<RelationalModelChange> PreFilter(IEnumerable<RelationalModelChange> changes)
{
List<RelationalModelChange> filtered = new List<RelationalModelChange>(changes);
foreach (RelationalModelChange change in changes)
{
// if a primary key is being added
if (change is AddPrimaryKeyChange)
{
// check if the table is being added, in which case
// the primary key will be embedded in the CREATE TABLE statement
if (IsTableAdded(changes, change.Table))
filtered.Remove(change);
}
// if a primary key is being dropped
if (change is DropPrimaryKeyChange)
{
// check if the table is being dropped, in which case
// the primary key will be dropped automatically
if (IsTableDropped(changes, change.Table))
filtered.Remove(change);
}
}
return base.PreFilter(filtered);
}