Click here to Skip to main content
15,891,372 members
Home / Discussions / C#
   

C#

 
GeneralRe: 2d drawing (visualstudio2005) Pin
lor3n7o3-May-09 4:15
lor3n7o3-May-09 4:15 
GeneralRe: 2d drawing (visualstudio2005) Pin
Henry Minute3-May-09 4:24
Henry Minute3-May-09 4:24 
GeneralRe: 2d drawing (visualstudio2005) Pin
lor3n7o3-May-09 4:34
lor3n7o3-May-09 4:34 
QuestionError related access-" Record(s) cannot be read; no read permission on 'MSysObjects '" Pin
KIDYA3-May-09 2:08
KIDYA3-May-09 2:08 
AnswerRe: Error related access-" Record(s) cannot be read; no read permission on 'MSysObjects '" Pin
MumbleB3-May-09 2:54
MumbleB3-May-09 2:54 
QuestionAre "Master pages" ASP.NET's answer to Template Engine for .NET 2.0? Pin
Member 3653373-May-09 2:00
Member 3653373-May-09 2:00 
AnswerRe: Are "Master pages" ASP.NET's answer to Template Engine for .NET 2.0? Pin
saanj3-May-09 21:21
saanj3-May-09 21:21 
QuestionGenerics return type cannot cast. Pin
NT9863-May-09 0:40
NT9863-May-09 0:40 
I cannot get generics to return a type that it does not know is correct.

I have a collection of general objects each with a sorted keyfield ID
cTypeA 2
cTypeB 3
cTypeA 7
cTypeA 9
cTypeB 12
in one ArrayList, all of which derive from cType.

I want to create a separate list of ID references using generics, but which returns the actual objects in an indexer. That way I am assured of type safety when using the object (displaying in a listview say) rather than casting at the end use point:

public class cList<T>
{
    public cList(cIDList UseOwner)
    {
	Owner = UseOwner;
        ListItems = new ArrayList();
    }

    public T this[int Index]
    {
        get
	{
	    if ((Index >= 0) && (Index < ListItems.Count))
	    {    return (T) Owner.GetObject((int)ListItems[Index]);    //***problem cannot implicitely convert to type T
	    }
	}
    }
    private cIDList Owner;
    private ArrayList ListItems;	//would contain 2,7,9
}

to implement this
cList<cTypeA> AItem = new cList<cTypeA>(MyIDList);
(assume items added)
cTypeA UseA = AItem[2];

Is there a way to solve this problem? The only way I can see is to do the above without generics, copy and paste then change the return cast type for what I use now, and in the future. Not easily manageable!

Thanks.
AnswerRe: Generics return type cannot cast. [modified] Pin
Thomas Weller3-May-09 5:27
Thomas Weller3-May-09 5:27 
AnswerRe: Generics return type cannot cast. Pin
PIEBALDconsult3-May-09 5:31
mvePIEBALDconsult3-May-09 5:31 
Questionhelp Pin
hotthoughtguy2-May-09 23:09
hotthoughtguy2-May-09 23:09 
AnswerRe: help Pin
Eddy Vluggen2-May-09 23:49
professionalEddy Vluggen2-May-09 23:49 
GeneralRe: help Pin
hotthoughtguy3-May-09 1:07
hotthoughtguy3-May-09 1:07 
GeneralRe: help Pin
Eddy Vluggen3-May-09 1:51
professionalEddy Vluggen3-May-09 1:51 
GeneralRe: help Pin
Dave Kreskowiak3-May-09 4:19
mveDave Kreskowiak3-May-09 4:19 
QuestionI want to control some hardware by internet Pin
rashed.info2-May-09 21:35
rashed.info2-May-09 21:35 
AnswerRe: I want to control some hardware by internet Pin
Mycroft Holmes2-May-09 23:45
professionalMycroft Holmes2-May-09 23:45 
AnswerRe: I want to control some hardware by internet Pin
Eddy Vluggen2-May-09 23:46
professionalEddy Vluggen2-May-09 23:46 
QuestionUnable to find a version .......... [modified] Pin
Thaer Hamael2-May-09 20:39
Thaer Hamael2-May-09 20:39 
AnswerRe: Unable to find a version .......... Pin
Luc Pattyn3-May-09 0:25
sitebuilderLuc Pattyn3-May-09 0:25 
GeneralRe: Unable to find a version .......... Pin
Thaer Hamael3-May-09 1:08
Thaer Hamael3-May-09 1:08 
Questioninput equation from text box Pin
Mehrdad from iran2-May-09 19:08
Mehrdad from iran2-May-09 19:08 
AnswerRe: input equation from text box Pin
Dave Kreskowiak2-May-09 19:28
mveDave Kreskowiak2-May-09 19:28 
AnswerRe: input equation from text box Pin
PIEBALDconsult3-May-09 5:34
mvePIEBALDconsult3-May-09 5:34 
QuestionMSDN C# Related...? Pin
jas0n232-May-09 17:34
jas0n232-May-09 17:34 

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.