473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Adding Items to a List

Hi,
Please find the code below. Now if I need to add items to the list how should I do that, any help is appriciated.

Expand|Select|Wrap|Line Numbers
  1.  class GenericProperties
  2.     {
  3.         private string UserName;
  4.         private string Password;
  5.         private bool PwdStrength;
  6.         private int Salary;
  7.  
  8.         public string _UserName
  9.         {
  10.             get { return  UserName; }
  11.             set { UserName = value; }
  12.         }
  13.  
  14.         public bool _PwdStrength
  15.         {
  16.             get { return PwdStrength; }
  17.             set { PwdStrength = value; }
  18.         }
  19.  
  20.         public string _Password
  21.         {
  22.             get { return Password; }
  23.             set { Password = value; }
  24.         }
  25.  
  26.         public int _Salary
  27.         {
  28.             get { return Salary; }
  29.             set { Salary = value; }
  30.         }
  31.  
  32.         public IList<GenericProperties> GetDataByName(GenericProperties GProperties)
  33.         {
  34.             IList<GenericProperties> lstGP = new List<GenericProperties>();
  35.             if ("Raghul".Equals(GProperties.UserName))
  36.             {
  37.                 // Here I need to add the items to the LIST and return them
  38.             }
  39. return lstGP;
  40.         }
  41.     }
  42.  
  43. static void Main(string[] args)
  44.         {
  45. GenericProperties GP = new GenericProperties();
  46.             IList<GenericProperties> lstGP = new List<GenericProperties>();
  47. GP._UserName = "Raghul";
  48.             lstGP = GP.GetDataByName(GP);
  49. }
  50.  
Mar 25 '11 #1
1 1982
GaryTexmo
1,501 Expert 1GB
You probably don't need to use the interface since it's going to be typed anyway, but you just need to use the Add method. Check the MSDN documentation on the List<T> class.

http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

That shows you all the methods and properties, as well as an example at the bottom.
Mar 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: R.G. Vervoort | last post by:
Not sure if it is a php question but since i am working in php here it is. Ho can i add items to (the item label=visual text and the value=index number) a list object on a website. I am having...
2
by: R.G. Vervoort | last post by:
Ho can i add items to (the item label=visual text and the value=index number) a list object on a website. I am having a list with 4 items and i would like to add the text from a textfield...
2
by: cybertof | last post by:
Hello, Is there a solution to the following problem : When filling a listview (30 columns) with around 5000 items, it can take easily 10 sec for the listview to be filled. I have used...
2
by: Chris | last post by:
I was wondering if there was any way to add a blank list item control to the beginning of the System.Web.UI.WebControls.DropDownList's datasource after the control's datasource has been specified....
5
by: Brian Henry | last post by:
I am trying to add some items to a list box in java script, they add just fine, the values and text are how they should be. The problem though is when I try to access these added items from asp.net...
1
by: bill | last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML <select runat=server>) using clientside javascript, and retrieve the items when the page is posted back. I use this code to...
2
by: =?Utf-8?B?TWFobW91ZCBTaGFiYW4=?= | last post by:
i have a problem in adding new listbox items i don't need to allow adding multible items with the same textvalue ex: if current items are: green red
2
by: ramya naidu | last post by:
Hai iam working with list and i have added items to list and how can i find whether the items are added to list or not using windows applications using c# and how can i display the items in list in...
0
by: Steve K. | last post by:
I understand the concepts and rules for invoking UI methods from a non-UI thread. In the past I have always checked with the control's InvokeRequired property and Invoked my delegate accordingly. ...
2
by: =?Utf-8?B?RHJEQkY=?= | last post by:
I understand that the Value put into a DataGridViewComboBoxCell has to be a member of the Items list or an exception is thrown. I also understand that you can override that exception by handling...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.