Click here to Skip to main content
15,919,613 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Polymorphic object comparison Pin
Benny_Lava10-Jun-10 0:55
Benny_Lava10-Jun-10 0:55 
AnswerRe: C# Polymorphic object comparison Pin
OriginalGriff9-Jun-10 23:47
mveOriginalGriff9-Jun-10 23:47 
GeneralRe: C# Polymorphic object comparison Pin
Łukasz Nowakowski10-Jun-10 0:31
Łukasz Nowakowski10-Jun-10 0:31 
GeneralRe: C# Polymorphic object comparison Pin
Benny_Lava10-Jun-10 0:57
Benny_Lava10-Jun-10 0:57 
AnswerRe: C# Polymorphic object comparison Pin
LookSharp11-Jun-10 13:13
LookSharp11-Jun-10 13:13 
Questioncrystal reports and c# (report directly with parameters). Pin
Absoluto9-Jun-10 22:10
Absoluto9-Jun-10 22:10 
AnswerRe: crystal reports and c# (report directly with parameters). Pin
Adam R Harris10-Jun-10 5:52
Adam R Harris10-Jun-10 5:52 
QuestionIntelliSense bug in VS2005 Pin
Mc_Topaz9-Jun-10 21:54
Mc_Topaz9-Jun-10 21:54 
I have stumbled on some bug with IntelliSense in Visual Studio 2005.
The bug/problem is that IntelliSense don't display the drop-down-list for a class instance returned by a method.

Here is a sample code (Don't mind the compile error in the Main()-method, we will get to it):

class Program
{
    static List<Car> carList = new List<Car>();
    static Cars cars;

    static void Main(string[] args)
    {
        carList.Add(new Car("Black", "Volvo"));
        carList.Add(new Car("Blue", "Volvo"));
        carList.Add(new Car("Black", "Audi"));
        cars = new Cars(carList);

        string c = cars["Volvo"]   // IntelliSense  don't work

        foreach (Car car in cars["Volvo", "Blue"])
            Console.WriteLine(car.Color + " : "+ car.Model);
    }
}

class Cars
{
    List<Car> carList;

    public Cars(List<Car> carList)
    {
        this.carList = carList;
    }

    public Car this[string model]
    {
        get
        {
            foreach (Car car in carList)
            {
                if (car.Model == model)
                    return car;
            }
            return null;
        }
    }

    public List<Car> this[string model, string color]
    {
        get
        {
            List<Car> cars = new List<Car>();

            foreach (Car car in cars)
            {
                if (car.Model == model && car.Color == color)
                    cars.Add(car);
                    
            }
            return cars;
        }
    }
}

class Car
{
    string color;
    string model;

    public Car(string color, string model)
    {
        this.color = color;
        this.model = model;
    }

    public string Color
    {
        get { return color; }
        set { color = value; }
    }

    public string Model
    {
        get { return model; }
        set { model = value; }
    }
}


Notice the cars["Volvo"] in the Main()-method which returns a Car-type instance. I want to pass the Color property to the string c variable.

When I want the drop-down-list to show the properties of the Car instance cars["Volvo"]. it's gone.
I can still pass the car instance's Color property to the string c variable but I have to manually type: .Color;.

I dug in this a bit deeper and found out if you comment out:
public List<Car> this[string model, string color] property in the Cars class,
the IntelliSense is back working and the cars["Volvo"]. displays the drop-down-list.


I made a new property in the Cars class.
The public List<Car> this[string model, string color] was still commented out.
public List<Car> this[int amounth]
{
    get
    {
        List<Car> list = new List<Car>();

        for (int i = 0; i < amounth; i++)
            list.Add(carList[i]);

        return list;
    }
}


Same result in the Main() method.

I guess this is a bug in the IntelliSense. Can I fix this in some way?

/Steffe!
AnswerRe: IntelliSense bug in VS2005 Pin
#realJSOP10-Jun-10 4:29
professional#realJSOP10-Jun-10 4:29 
GeneralRe: IntelliSense bug in VS2005 Pin
Mc_Topaz10-Jun-10 4:38
Mc_Topaz10-Jun-10 4:38 
GeneralRe: IntelliSense bug in VS2005 Pin
dybs12-Jun-10 10:19
dybs12-Jun-10 10:19 
Question.net framework 4 Pin
michaelgr19-Jun-10 20:46
michaelgr19-Jun-10 20:46 
AnswerRe: .net framework 4 Pin
Abhinav S9-Jun-10 21:01
Abhinav S9-Jun-10 21:01 
AnswerRe: .net framework 4 Pin
Pete O'Hanlon9-Jun-10 21:38
mvePete O'Hanlon9-Jun-10 21:38 
QuestionMicrosoft sync framework Pin
hadad9-Jun-10 20:37
hadad9-Jun-10 20:37 
Questionhow to recognize the identityfing code in the image Pin
yu-jian9-Jun-10 20:16
yu-jian9-Jun-10 20:16 
QuestionTextureBrush problem Pin
Xmen Real 9-Jun-10 17:41
professional Xmen Real 9-Jun-10 17:41 
AnswerRe: TextureBrush problem Pin
Luc Pattyn9-Jun-10 17:58
sitebuilderLuc Pattyn9-Jun-10 17:58 
GeneralRe: TextureBrush problem Pin
Xmen Real 10-Jun-10 4:31
professional Xmen Real 10-Jun-10 4:31 
QuestionError in printing Pin
future38399-Jun-10 13:45
future38399-Jun-10 13:45 
AnswerRe: Error in printing Pin
Luc Pattyn9-Jun-10 14:04
sitebuilderLuc Pattyn9-Jun-10 14:04 
GeneralRe: Error in printing Pin
future38399-Jun-10 14:20
future38399-Jun-10 14:20 
GeneralRe: Error in printing Pin
Luc Pattyn9-Jun-10 14:36
sitebuilderLuc Pattyn9-Jun-10 14:36 
QuestionExceptions From Threads Pin
JohnLBevan9-Jun-10 12:03
professionalJohnLBevan9-Jun-10 12:03 
AnswerRe: Exceptions From Threads Pin
Luc Pattyn9-Jun-10 12:52
sitebuilderLuc Pattyn9-Jun-10 12:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.