本文整理汇总了C#中Common.List.Add方法的典型用法代码示例。如果您正苦于以下问题:C# List.Add方法的具体用法?C# List.Add怎么用?C# List.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetState
public static SelectList GetState()
{
List<object> sl = new List<object>();
sl.Add(new { Id = "未审核", Text = "未审核" });
sl.Add(new { Id = "已审核", Text = "已审核" });
return new SelectList(sl, "Id", "Text");
}
示例2: Main
private static void Main()
{
// Generate random data to test functionality
List<IShape> shapes = new List<IShape>();
for (int i = 0; i < 12; i++)
{
if (i < 4)
{
// Make Triangle
IShape shape = GetShape(typeof(Triangle));
shapes.Add((Triangle)shape);
}
else if (i < 8)
{
// Make Rectangle
IShape shape = GetShape(typeof(Rectangle));
shapes.Add((Rectangle)shape);
}
else
{
// Make Circle
IShape shape = GetShape(typeof(Circle));
shapes.Add((Circle)shape);
}
}
// Print result
shapes.ForEach(x => Console.WriteLine(x));
}
示例3: GetProxyParticlesAddresses
public Uri[] GetProxyParticlesAddresses()
{
var uris = new List<Uri>();
if (_left != null) uris.Add(_left.Item2.Address);
if (_right != null) uris.Add(_right.Item2.Address);
return uris.ToArray();
}
示例4: GrabWeatherInfos
public IEnumerable<WeatherInfo> GrabWeatherInfos(List<string> cityNames)
{
var weatherInfos = new List<WeatherInfo>();
foreach (var cityName in cityNames)
{
string city = cityName;
var weatherInfo = _cache.ContainsKey(city) ? _cache[city] : _weatherInfoRepository.Get(p => p.CityName == city);
if ((weatherInfo == null) || (_dateTimeProvider.UtcNow() - weatherInfo.LastUpdated) > TimeSpan.FromHours(4))
{
var aggregatedWeatherInfo = _weatherWeatherServiceAggregator.Aggregate(city);
if (weatherInfo != null)
{
aggregatedWeatherInfo.Id = weatherInfo.Id;
_weatherInfoRepository.Update(aggregatedWeatherInfo);
_cache[city] = aggregatedWeatherInfo;
}
else
{
_weatherInfoRepository.Save(aggregatedWeatherInfo);
_cache[city] = aggregatedWeatherInfo;
}
weatherInfos.Add(aggregatedWeatherInfo);
}
else
{
weatherInfos.Add(weatherInfo);
}
}
return weatherInfos;
}
示例5: GenerateAnimals
private static List<IAnimal> GenerateAnimals()
{
List<IAnimal> animals = new List<IAnimal>();
for (int i = 0; i < 20; i++)
{
string name = GenerateRandom.Text(GenerateRandom.Number(5, 15));
int age = GenerateRandom.Number(5, 35);
if (i < 5)
{
Tomcat tomcat = new Tomcat(age, name);
animals.Add(tomcat);
}
else if (i > 5 && i < 10)
{
Kitten kitten = new Kitten(age, name);
animals.Add(kitten);
}
else if (i > 10 && i < 15)
{
Dog dog = new Dog(age, name);
animals.Add(dog);
}
else
{
Frog frog = new Frog(age, name);
animals.Add(frog);
}
}
return animals;
}
示例6: Descomprimir_Pixel
public static byte[] Descomprimir_Pixel(byte[] datos, byte depth)
{
if (depth % 8 != 0)
throw new NotImplementedException("Profundidad no soportada: " + depth.ToString());
List<byte> des = new List<byte>();
for (int pos = 0; pos < datos.Length; )
{
if (datos[pos] >= 0x80)
{
int rep = datos[pos] - 0x80 + 1;
pos++;
for (; rep > 0; rep--)
for (int d = 0; d < (depth / 8); d++)
des.Add(datos[pos]);
}
else
{
int rep = datos[pos] + 1;
pos++;
for (; rep > 0; rep--)
for (int d = 0; d < (depth/8); d++, pos++)
des.Add(datos[pos]);
}
pos++;
}
return des.ToArray();
}
示例7: ContactsController
static ContactsController()
{
contacts = new List<Contact>();
contacts.Add(new Contact{Id = "001",Name = "zhangsan",PhoneNo = "1231231",EmailAddress = "[email protected]",Address = "江苏苏州"});
contacts.Add(new Contact(){Id = "002",Name = "lisi",PhoneNo = "14322222222",EmailAddress = "[email protected]",Address = "jiangsu xuzhou"});
}
示例8: GetRulesForPickList
public IList<IPickListRule> GetRulesForPickList()
{
List<IPickListRule> testRules = new List<IPickListRule>();
testRules.Add(new SpouseRule(mFamily));
testRules.Add(new ChristmasPastRule(mArchive, mYearsBack));
return testRules;
}
示例9: SetPropertiesBytes
void SetPropertiesBytes()
{
var binProperties = new List<BinProperty>();
binProperties.Add(new BinProperty()
{
No = 0,
Value = PumpStation.Delay
});
binProperties.Add(new BinProperty()
{
No = 1,
Value = PumpStation.Hold
});
binProperties.Add(new BinProperty()
{
No = 2,
Value = (ushort)PumpStation.DelayRegime
});
foreach (var binProperty in binProperties)
{
Parameters.Add(binProperty.No);
Parameters.AddRange(BitConverter.GetBytes(binProperty.Value));
Parameters.Add(0);
}
}
示例10: InvestMoney
public void InvestMoney()
{
int numberOfInvestments = numberOfMembers;
//The index doing the investing:
for(int i=0 ;i < numberOfMembers; i++){
var investor = this.Members[i];
List<double> partitions = new List<double>();
//Generate N random numbers
for (int j = 0; j < numberOfInvestments -1 ; j++) {
partitions.Add(rand.NextDouble());
}
partitions.Add(1);
//Sort the numbers
partitions.Sort();
//Each partition corresponds to the investment amount in order
//The index getting the investment
double totalPercentInvested = 0;
double totalMoneyInvested = 0;
for (int j = 0; j < numberOfInvestments; j++) {
double percentToInvest = (partitions[j] - totalPercentInvested);
var investee = this.Members[j];
investee.TakeInvestment(investor, percentToInvest * investor.GetAssets());
totalMoneyInvested += percentToInvest * investor.GetAssets() ;
totalPercentInvested += percentToInvest;
}
//Debug.Print("Total percent invested: " + totalPercentInvested.ToString());
//Debug.Print("Total monies invested: " + totalMoneyInvested.ToString());
}
}
示例11: FilterProducts
public PartialViewResult FilterProducts(ProductFilterModel model)
{
List<Product> p = new WCFProduct().GetProducts().ToList();
List<ProductModel> products = new List<ProductModel>();
foreach (Product pr in p)
{
ProductModel pm = new ProductModel();
pm.ID = pr.ID;
pm.Features = pr.Features;
pm.DateListed = pr.Date_Listed;
pm.Name = pr.Name;
pm.Image = pr.Image;
pm.Price = (double)pr.Price;
pm.StockAmount = pr.Stock_Amount;
pm.AverageRate = new WCFProductClient().GetProductAverageRating(pr.ID);
if (model.CategoryName != null)
{
if (pr.Category != null && pr.Category.Contains(model.CategoryName))
{
products.Add(pm);
}
}
else if (model.ProductName != null)
{
if (pm.Name.Contains(model.ProductName))
{
products.Add(pm);
}
}
else if (model.smallestPrice != 0 && model.greatestPrice != 0 && model.smallestPrice != null && model.greatestPrice != null)
{
if (pm.Price >= model.smallestPrice && pm.Price <= model.greatestPrice)
{
products.Add(pm);
}
}
else
{
products.Add(pm);
}
if (model.sortByPrice == true)
{
if (model.sortDescending == true)
{
products = products.OrderByDescending(temP => temP.Price).ToList();
}
else
{
products = products.OrderBy(temP => temP.Price).ToList();
}
}
}
return PartialView("_Filters", products);
}
示例12: FindFile
/// <summary>
/// 获取路径下所有邮件
/// </summary>
/// <param name="sSourcePath">路径</param>
/// <returns>返回邮寄路径集合</returns>
public List<string> FindFile(string sSourcePath)
{
List<String> list = new List<string>();
//遍历文件夹
DirectoryInfo theFolder = new DirectoryInfo(sSourcePath);
FileInfo[] thefileInfo = theFolder.GetFiles("*.*", SearchOption.TopDirectoryOnly);
//遍历文件
foreach (FileInfo NextFile in thefileInfo)
{
list.Add(NextFile.FullName);
}
//遍历子文件夹
DirectoryInfo[] dirInfo = theFolder.GetDirectories();
foreach (DirectoryInfo NextFolder in dirInfo)
{
//list.Add(NextFolder.ToString());
FileInfo[] fileInfo = NextFolder.GetFiles("*.emal", SearchOption.AllDirectories);
foreach (FileInfo NextFile in fileInfo) //遍历文件
list.Add(NextFile.FullName);
}
return list;
}
示例13: RetrievePerson
/// <summary>
/// Reset alert collection for Guest
/// </summary>
/// <param name="message">The message.</param>
/// <param name="eventType">Instance of NotificationEventType</param>
public static void RetrievePerson(NotificationEvent message, NotificationEventType eventType)
{
List<PersonType> personTypeList = new List<PersonType>();
if (message != null && message.PersonTypeId == CommonConstants.GuestTypeId)
{
personTypeList.Add(PersonType.Guest);
}
else if (message != null && message.PersonTypeId == CommonConstants.CrewmemberTypeId)
{
personTypeList.Add(PersonType.Crewmember);
}
else if (message != null && message.PersonTypeId == CommonConstants.VisitorTypeId)
{
personTypeList.Add(PersonType.Visitor);
}
if (eventType == NotificationEventType.Reservation)
{
RetrieveGuestForReservation(message, eventType, personTypeList);
}
else
{
RetrieveGuest(message, eventType, personTypeList);
}
}
示例14: addCustomerInfo
/**
* 添加客户信息到数据库中
* @param List<Object> list:添加到数据库中的数据集
* @return int 值为Constant.OK:执行成功,值为Constant.ERROR为执行出错
* @author Rick
**/
public int addCustomerInfo(ref List<Object> list)
{
Customer customer = (Customer)list[0];
Countfeeinfo countfeeinfo = (Countfeeinfo)list[1];
PriceRate priceRate = null;
//在CustomerInfo表中新增signFlag项
string customerSql = "insert into CustomerInfo values('" + customer.getCustomerNo() + "', '" + customer.getCustomerName() + "', '" + customer.getIdentificationCard() + "',, '" + customer.getCustomerAddress() + "', " + customer.getLine() + ", " + customer.getArea() + ", '" + customer.getInvoiceType() + "', '" + customer.getElectriCharacterName() + "', '" + customer.getVoltageFlag() + "', '" + customer.getAmmeterType() + "', '" + customer.getAmmeterNo() + "', '" + customer.getBankCode() + "', '" + customer.getBankName() + "', '" + customer.getBankAccount() + "', '" + customer.getSignFlag() + "', '" + customer.getTradeCode() + "', '" + customer.getValueAddTaxNo() + "', " + customer.getOrganFlag() + ", " + customer.getEspecialFlag() + "," + customer.getLowProtectFlag() + "," + customer.getTranslossOrBaseprice() + ", getdate(), null, " + customer.getCustomerPosition() + ",'" + customer.getPhoneNum() + "')";
string countfeeSql = "insert into CountFeeInfo values('" + countfeeinfo.getCustomerNo() + "', " + countfeeinfo.getTransformerNo() + ", " + countfeeinfo.getAmmeterMulti() + ", null, " + countfeeinfo.getLineLoseRate() + ", 0, getDate(), " + countfeeinfo.getDiscountRate() + ")";
List<string> sqlList = new List<string>();
sqlList.Add(customerSql);
sqlList.Add(countfeeSql);
int nums = list.Count;
while (nums > 2)
{
priceRate = (PriceRate)list[nums - 1];
string priceSql = "insert into PriceRate values('" + priceRate.PriceName + "'," + priceRate.PriceNo + ", " + priceRate.Rate + ", getdate())";
sqlList.Add(priceSql);
nums = nums - 1;
}
try
{
SQLUtl.ExecuteSqlTran(sqlList);
return Constant.OK;
}
catch (Exception)
{
return Constant.ERROR;
}
}
示例15: MergeItems
private List<CalendarItem> MergeItems(List<CalendarItem> newItems, List<CalendarItem> fromRepo)
{
var result = new List<CalendarItem>();
var newModels = newItems.Except(fromRepo, new CalendarItemEqualityComparer()).ToList();
var updatet = fromRepo.Except(newModels,new CalendarItemEqualityComparer()).ToList();
updatet.ForEach(x =>
{
var model = newItems.FirstOrDefault(y => y.Id == x.Id);
if (model != null)
{
model.SyncStatus.CalenadCalendarItemStatus = IsModified(model, x)
? CalendarItemStatus.Updated
: CalendarItemStatus.Unmodified;
result.Add(model);
}
});
var deleted = fromRepo.Where(x => x.Start.Date >= DateTime.Now.Date).Except(newItems).Except(updatet);
newModels.ForEach(x => x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.New);
deleted.ForEach(x =>
{
x.SyncStatus.CalenadCalendarItemStatus = CalendarItemStatus.Deleted;
result.Add(x);
});
result.AddRange(newModels);
return result.OrderBy(x => x.Start).ToList();
}