resize

  • Thread starter Thread starter Deniel Rose'
  • Start date Start date
Hi Deniel,

If it's some sort of list Control to which you are referring then:

- for WinForms set any of the Bounds, ClientSize, Size, Width or Height
properties

- for WebControl set the Width or Height properties or add custom attributes
and styles.
 
class A {
public int a;
}
private void func()
{
List<A> aref=new List<A>();
//dosometing
aref.resize(10000); <------ This is what i want to do
}

But there is no resize() implemeted.
Thanks for any help
 
Thanks Dave for your answer,
I still wonder how i can sort the list based on the comparison of "a"
values

I mean
private bool comp(A aref, A bref)
{
return aref.a<bref.a;
}
if i put this function in a icomparable, implementation may become
complex,
built-in sort of List can't do this, can it ? How can I make a sort()
then ?
 
Hi Deniel,
here is an example of how you can sort the contents of your list using an
anonymous delegate, which makes it very simple to sort the items in the list:

class Person
{
private string name;

public Person(string name)
{
this.name = name;
}

public string Name
{
get
{
return this.name;
}
}
}
static void Main(string[] args)
{
List<Person> people = new List<Person>();

Person mark = new Person("mark");
Person bob = new Person("bob");
Person frank = new Person("frank");

people.Add(mark);
people.Add(bob);
people.Add(frank);

people.Sort(delegate(Person p1, Person p2)
{
return p1.Name.CompareTo(p2.Name);
}
);

for (int i = 0; i < people.Count; ++i)
{
Console.Out.WriteLine(people.Name);
}

Console.ReadLine();
}

HTH
Mark.
 
Hi Deniel,

Try the following code:

List<int> list = new List<int>();
list.Add(10);
list.Add(3);
list.Add(16);

list.Sort(
delegate(int i1, int i2) // anonymous method
{
return i1.CompareTo(i2);
});
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top