本文整理汇总了C#中List.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# List.Concat方法的具体用法?C# List.Concat怎么用?C# List.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类List
的用法示例。
在下文中一共展示了List.Concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TercerRonda
public void TercerRonda(Jugador dealer)
{
List<Cartas> listaTercerRondaDealer = dealer.RepartirCartasRonda(1);
cartasDealer = cartasDealer.Concat(listaTercerRondaDealer).ToList();
for (int i = 0; i < listaTercerRondaDealer.Count; i++)
{
cartaVista7.Nombre = listaTercerRondaDealer[i].Nombre;
cartaVista7.Palo = listaTercerRondaDealer[i].Palo;
}
ronda = 3;
jugDealer = dealer;
//sACAR LALISTA DE CARTAS DEL JUGADOR 1
List<Cartas> cartasJug1Total = cartasDealer.Concat(cartasJ1).ToList();
//Sacar la lista de las cartas del jugador 2
List<Cartas> cartasJug2Total = cartasDealer.Concat(cartasJ2).ToList();
int jugada1 = new Jugador().ValidarJugadaGanadora(cartasJug1Total.OrderBy(x => x.Valor).ToList());
int jugada2 = new Jugador().ValidarJugadaGanadora(cartasJug2Total.OrderBy(x => x.Valor).ToList());
for (int i = 0; i < cartasJ2.Count; i++)
{
if (i == 0)
{
cartaVista8.Nombre = cartasJ2[i].Nombre;
cartaVista8.Palo = cartasJ2[i].Palo;
}
if (i == 1)
{
cartaVista9.Nombre = cartasJ2[i].Nombre;
cartaVista9.Palo = cartasJ2[i].Palo;
}
}
MessageBox.Show("Jugador 1:" + MostrarJugada(jugada1) + Environment.NewLine + Environment.NewLine + " Jugador 2:" + MostrarJugada(jugada2));
}
示例2: Menu
public PartialViewResult Menu()
{
var user = CurrentUser;
IEnumerable<NavigationItem> navItems = new List<NavigationItem>();
var pages = RolePagesMap.Pages;
navItems = navItems.Concat(RolePagesMap.CommonPages).Distinct();
if (user.IsAlumni())
{
navItems = navItems.Concat(pages[UserRoleType.Alumni]);
}
if (user.IsStudent())
{
navItems = navItems.Concat(pages[UserRoleType.Student]);
}
if (user.IsAdmin())
{
navItems = navItems.Concat(pages[UserRoleType.Admin]);
}
var txtItems = navItems.Where(n => string.IsNullOrEmpty(n.ImageUrl));
var imgItems = navItems.Where(n => !string.IsNullOrEmpty(n.ImageUrl));
var vm = new NavigationVm
{
TextItems = txtItems,
ImageItems = imgItems,
SelectePage = CurrentPage,
};
return PartialView(vm);
}
示例3: Evolve
public IEnumerable<IBe> Evolve(Action<IEnumerable<IBe>, int> perIteractionAction)
{
currentIteration = 0;
while (currentIteration <= god.maximunIteration)
{
List<IBe> currentPopulation = new List<IBe>();
for (int i = 0; i < god.maximunOffspring; i++)
{
var operation = randomOperation.GetOperation();
switch (operation)
{
case Operations.Mutation:
currentPopulation = currentPopulation.Concat(darwin.Mutate(god.GetSingle(population, i))).ToList();
break;
case Operations.CrossOver:
var couple = god.GetCouple(population, i);
currentPopulation = currentPopulation.Concat(darwin.Conceive(couple.Item1, couple.Item2)).ToList();
break;
}
}
population = population.Union(darwin.CalculateSolution(currentPopulation)).OrderBy(n => -n.Solution).Distinct(comparer).Take(god.maximunOffspring).ToList();
if (perIteractionAction != null) perIteractionAction.Invoke(population, currentIteration);
currentIteration++;
}
return population;
}
示例4: ConcatWorks
public void ConcatWorks()
{
var list = new List<string> { "a", "b" };
Assert.AreEqual(list.Concat("c"), new[] { "a", "b", "c" });
Assert.AreEqual(list.Concat("c", "d"), new[] { "a", "b", "c", "d" });
Assert.AreEqual(list, new[] { "a", "b" });
}
示例5: Index
public ActionResult Index()
{
string userId = User.Identity.GetUserId();
List<string> userRolesList = UserManager.GetRoles(userId).ToList();
IEnumerable<IWorkListItems> workListItemsToDisplay = new List<IWorkListItems>();
workListItemsToDisplay = workListItemsToDisplay.Concat(GetWorkOrders(userId, userRolesList));
workListItemsToDisplay = workListItemsToDisplay.Concat(GetWidgets(userId, userRolesList));
return View(workListItemsToDisplay.OrderByDescending(wl => wl.PriorityScore));
}
示例6: GetWPFConnectionsForProject
public IEnumerable<ClientConnection> GetWPFConnectionsForProject(int projectId)
{
IList<ClientConnection> connections = new List<ClientConnection>();
var users = projectRepository.GetAllUsersInProject(projectId);
foreach (var user in users)
{
connections.Concat(SignalRClients.Connections.Where(x => x.UserName == user.UserName).ToList());
}
var creator = projectRepository.GetCreatorForProject(projectId);
List<ClientConnection> creatorConnections =
SignalRClients.Connections.Where(x => x.UserName == creator.UserName && x.IsWPFClient).ToList();
return connections.Concat(creatorConnections);
}
示例7: GenerateAbilitiesFile
protected void GenerateAbilitiesFile(LegionDatabase Database)
{
// Load ability templates
string SummonAbilityTemplate = LoadTemplateFile(SPAWN_UNIT_TEMPLATE);
string UpgradeAbilityTemplate = LoadTemplateFile(UPGRADE_UNIT_TEMPLATE);
// Generate data from each unit
List<string> SummonAbilities = GenerateDataForList<LegionUnit>(SummonAbilityTemplate, GetSummonableUnits(Database), "Unit");
List<string> UpgradeAbilities = GenerateDataForList<LegionUnit>(UpgradeAbilityTemplate, GetUpgradeUnits(Database), "Unit");
// Generate data for unit abilities
List<string> UnitAbilities = new List<string>();
foreach (LegionUnit Unit in Database.GetUnits())
{
foreach (LegionAbility Ability in Unit.LegionAbilities)
{
string AbilityFilePath = string.Format(UNIT_ABILITIES_TEMPLATE, Ability.AbilityFile);
string AbilityTemplate = LoadTemplateFile(AbilityFilePath);
AbilityTemplate = ProcessTemplate<LegionUnit>(AbilityTemplate, Unit, "Unit");
AbilityTemplate = ProcessTemplate<LegionAbility>(AbilityTemplate, Ability, "Ability");
UnitAbilities.Add(AbilityTemplate);
}
}
// Merge all data
List<string> GeneratedAbilitiesData = new List<string>();
GeneratedAbilitiesData = GeneratedAbilitiesData.Concat(SummonAbilities).ToList();
GeneratedAbilitiesData = GeneratedAbilitiesData.Concat(UpgradeAbilities).ToList();
GeneratedAbilitiesData = GeneratedAbilitiesData.Concat(UnitAbilities).ToList();
// Generate sell abilities for all heroes
foreach(LegionHero Hero in Database.GetHeroes())
{
string SellUnitTemplate = LoadTemplateFile(SELL_UNIT_ABILITY_TEMPLATE);
SellUnitTemplate = ProcessTemplate<LegionHero>(SellUnitTemplate, Hero, "Hero");
GeneratedAbilitiesData.Add(SellUnitTemplate);
}
// Add external data
foreach (string ExternalPath in EXTERNAL_ABILITIES)
{
string UnitData = LoadTemplateFile(ExternalPath);
GeneratedAbilitiesData.Add(UnitData);
}
// Generate file and save
string AbilityBuildFile = GenerateBuildFile(CUSTOM_ABILITIES_FILE, GeneratedAbilitiesData, "{Abilities}");
SaveDataToFile(CUSTOM_ABILITIES_OUTPUT, AbilityBuildFile);
}
示例8: GetFactors
private List<long> GetFactors(long number, long first, List<long> acc)
{
if (first > (number / first) || first > (number / 2))
{
return acc;
}
else if (number % first == 0)
{
return GetFactors(number, first + 1, acc.Concat(new List<long>() {first,(number / first)}).ToList());
}
else
{
return GetFactors(number, first + 1, acc.Concat(Enumerable.Empty<long>()).ToList());
}
}
示例9: IoDeviceRunTarget
public IoDeviceRunTarget(io_devices ioDevice, IIoDeviceWrapperFactory wrapperFactory, INotificationReporter reporter)
{
_reporter = reporter;
Name = string.Format(Res.IoDeviceWithName, ioDevice.name);
_filePath = GetFilePath(ioDevice.type);
_options = ioDevice.options;
_wrapperFactory = wrapperFactory;
var digReadParameters = new List<ReadParameter>();
var digReadValueHolders = new List<ITagValueHolder>();
foreach (var t in ioDevice.dig_tags)
{
var holder = new DigTagValueHolder(t);
_digValueHolders.Add(t.id, holder);
if (t.can_read)
{
digReadValueHolders.Add(holder);
digReadParameters.Add(new ReadParameter(t.device, typeof(bool)));
}
}
var numReadParameters = new List<ReadParameter>();
var numReadValueHolders = new List<ITagValueHolder>();
foreach (var t in ioDevice.num_tags)
{
var holder = new NumTagValueHolder(t);
_numValueHolders.Add(t.id, holder);
if (t.can_read)
{
numReadValueHolders.Add(holder);
numReadParameters.Add(new ReadParameter(t.device, t.TagType));
}
}
_readParameters = digReadParameters.Concat(numReadParameters).ToArray();
_readValueHolders = digReadValueHolders.Concat(numReadValueHolders).ToArray();
}
示例10: NHLPlayerSelectionForm
public NHLPlayerSelectionForm(List<Player> centerList, List<Player> wingerList,
List<Player> defenseList, List<Player> goalieList, int salaryCap, int salaryThreshold)
{
InitializeComponent();
mCenterList = centerList;
mWingerList = wingerList;
mDefenseList = defenseList;
mGoalieList = goalieList;
mUtilList = centerList.Concat(wingerList).Concat(defenseList).ToList();
fillComboBox(goalieBox, mGoalieList);
fillComboBox(centerBox1, mCenterList);
fillComboBox(centerBox2, mCenterList);
fillComboBox(defenseBox1, mDefenseList);
fillComboBox(defenseBox2, mDefenseList);
fillComboBox(wingerBox1, mWingerList);
fillComboBox(wingerBox2, mWingerList);
fillComboBox(wingerBox3, mWingerList);
fillComboBox(utilBox, mUtilList);
mTeamList = new List<Team>();
mSalaryCap = salaryCap;
mSalaryThreshold = salaryThreshold;
}
示例11: Main
static void Main()
{
string line1 = Console.ReadLine();
string[] firstLine = line1.Split(' ');
string line2 = Console.ReadLine();
string[] secondLine = line2.Split(' ');
List<int> firstList = new List<int>();
List<int> secondList = new List<int>();
List<int> joinedList = new List<int>();
for (int i = 0; i < firstLine.Length; i++)
{
firstList.Add(int.Parse(firstLine[i]));
}
for (int i = 0; i < secondLine.Length; i++)
{
secondList.Add(int.Parse(secondLine[i]));
}
joinedList = firstList.Concat(secondList).Distinct().ToList();
joinedList.Sort();
foreach (var item in joinedList)
{
Console.Write(item+" ");
}
Console.WriteLine();
}
示例12: Visit
/// <summary>
/// Visits the payload element
/// </summary>
/// <param name="payloadElement">The payload element to visit</param>
public override void Visit(EntityInstance payloadElement)
{
ExceptionUtilities.CheckArgumentNotNull(payloadElement, "payloadElement");
var properties = new List<PropertyInstance>();
var navprops = new List<PropertyInstance>();
foreach (var propertyInstance in payloadElement.Properties)
{
this.Recurse(propertyInstance);
var isnavprop = propertyInstance as NavigationPropertyInstance;
if (isnavprop != null)
{
navprops.Add(propertyInstance);
}
else
{
properties.Add(propertyInstance);
}
}
payloadElement.Properties = navprops.Concat(properties);
foreach (var serviceOperationDescriptor in payloadElement.ServiceOperationDescriptors)
{
this.Recurse(serviceOperationDescriptor);
}
}
示例13: WriteCreateInfoFromQueryStringMethod
internal static void WriteCreateInfoFromQueryStringMethod(
TextWriter writer, List<VariableSpecification> requiredParameters, List<VariableSpecification> optionalParameters, string methodNamePrefix,
string infoConstructorArgPrefix)
{
writer.WriteLine( methodNamePrefix + ( methodNamePrefix.Contains( "protected" ) ? "c" : "C" ) + "reateInfoFromQueryString() {" );
writer.WriteLine( "try {" );
var allParameters = requiredParameters.Concat( optionalParameters );
// Create a local variable for all query parameters to hold their raw query value.
foreach( var parameter in allParameters ) {
// If a query parameter is not specified, Request.QueryString[it] returns null. If it is specified as blank (&it=), Request.QueryString[it] returns the empty string.
writer.WriteLine(
"var " + getLocalQueryValueVariableName( parameter ) + " = HttpContext.Current.Request.QueryString[ \"" + parameter.PropertyName + "\" ];" );
}
// Enforce specification of all required parameters.
foreach( var parameter in requiredParameters ) {
// Blow up if a required parameter was not specified.
writer.WriteLine(
"if( " + getLocalQueryValueVariableName( parameter ) + " == null ) throw new ApplicationException( \"Required parameter not included in query string: " +
parameter.Name + "\" );" );
}
// Build up the call to the info constructor.
var infoCtorArguments = new List<string> { infoConstructorArgPrefix };
infoCtorArguments.AddRange( requiredParameters.Select( rp => getChangeTypeExpression( rp ) ) );
// If there are optional parameters, build an optional paramater package, populate it, and include it in the call to the info constructor.
if( optionalParameters.Count > 0 ) {
infoCtorArguments.Add( "optionalParameterPackage: optionalParameterPackage" );
writer.WriteLine( "var optionalParameterPackage = new OptionalParameterPackage();" );
foreach( var parameter in optionalParameters ) {
// If the optional parameter was not specified, do not set its value (let it remain its default value).
writer.WriteLine(
"if( " + getLocalQueryValueVariableName( parameter ) + " != null ) optionalParameterPackage." + parameter.PropertyName + " = " +
getChangeTypeExpression( parameter ) + ";" );
}
}
// Construct the info object.
writer.WriteLine( "info = new Info( " + StringTools.ConcatenateWithDelimiter( ", ", infoCtorArguments.ToArray() ) + " );" );
writer.WriteLine( "}" ); // Try block
writer.WriteLine( "catch( Exception e ) {" );
writer.WriteLine( "if( e is UserDisabledByPageException )" );
writer.WriteLine( "throw;" );
writer.WriteLine(
"throw new ResourceNotAvailableException( \"Query parameter values or non URL elements of the request prevented the creation of the page or entity setup info object.\", e );" );
writer.WriteLine( "}" ); // Catch block
// Initialize the parameters modification object.
if( allParameters.Any() ) {
writer.WriteLine( "parametersModification = new ParametersModification();" );
foreach( var parameter in allParameters )
writer.WriteLine( "parametersModification." + parameter.PropertyName + " = info." + parameter.PropertyName + ";" );
}
writer.WriteLine( "}" );
}
示例14: AddSelectedKnowledgesAsCurrentCompetencies
public ActionResult AddSelectedKnowledgesAsCurrentCompetencies(GaTask task)
{
string stringOfKnowledgesIds = Request["selectedIds"];
if (!stringOfKnowledgesIds.IsEmpty())
{
List<Competence> competencies = new List<Competence>();
HashSet<string> listOfKnIds = new HashSet<string>(stringOfKnowledgesIds.Split(',').ToList());
foreach (var id in listOfKnIds)
{
var kn = _dbContext.Ontology.Find(x => x.Id == ObjectId.Parse(id)).SingleOrDefaultAsync().Result;
if (kn != null)
{
competencies.Add(new Competence(kn.Id, BloomLevel.None));
}
}
if (task.Prerequisites == null)
{
task.Prerequisites = competencies.ToArray();
}
else
{
List<Competence> tmpList = new List<Competence>(task.Prerequisites);
tmpList.Concat(competencies);
task.Prerequisites = tmpList.ToArray();
}
}
return View("NewTask", task);
}
示例15: Autosuggest
public string Autosuggest(string autocomplete)
{
const string autocompletionName = "destination-suggest";
var response =
_elasticClient.Suggest<string>(suggest => suggest.Completion(autocompletionName, c => c.Size(100).OnField("suggest").Text(autocomplete).Fuzzy(fuzzy=> fuzzy.Fuzziness(1).Transpositions(false))));
var options = response.Suggestions[autocompletionName][0].Options;
var fuzzySuggestions = new List<Suggestion>();
var exactMatchSuggestions = new List<Suggestion>();
foreach (var option in options)
{
var suggestion = new Suggestion
{
Text = option.Text,
Payload = option.Payload,
Score = option.Score
};
if (option.Text.ToUpperInvariant().StartsWith(autocomplete.ToUpperInvariant()))
exactMatchSuggestions.Add(suggestion);
else fuzzySuggestions.Add(suggestion);
}
var suggestions = exactMatchSuggestions.Concat(fuzzySuggestions);
return JsonConvert.SerializeObject(suggestions.Select(y => y.Text).ToList());
}