Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Code seems to loops indefinitely Pin
Karthik S Prakash12-Dec-09 9:09
Karthik S Prakash12-Dec-09 9:09 
AnswerRe: Code seems to loops indefinitely Pin
Richard MacCutchan12-Dec-09 7:25
mveRichard MacCutchan12-Dec-09 7:25 
Questiondecode XmlDocument.OuterText Pin
giddy_guitarist12-Dec-09 6:10
giddy_guitarist12-Dec-09 6:10 
AnswerRe: decode XmlDocument.OuterText Pin
Migounette12-Dec-09 7:27
Migounette12-Dec-09 7:27 
AnswerRe: decode XmlDocument.OuterText Pin
PIEBALDconsult12-Dec-09 9:19
mvePIEBALDconsult12-Dec-09 9:19 
AnswerRe: decode XmlDocument.OuterText Pin
giddy_guitarist12-Dec-09 20:08
giddy_guitarist12-Dec-09 20:08 
QuestionSQL sync with SQLCE Pin
redspiderke12-Dec-09 3:19
redspiderke12-Dec-09 3:19 
QuestionReplace "inner list" of a generic class inheriting from List<T> ? Pin
BillWoodruff12-Dec-09 2:13
professionalBillWoodruff12-Dec-09 2:13 
Let's say you define this class (at the namespace level; i.e., outside
a form or whatever)
public class anyDamnList<T> : List<T>
{
    public anyDamnList() { }
}
And you declare and use it ... in a form's code ... with no problems :
anyDamnList<int> aYIntList = new anyDamnList<int>();
aYIntList.Add(100);
aYIntList.Add(200);

Console.WriteLine(aYIntList[1]);

List<int> intList3 = new List<int> { 9, 19, 22, 44 };

aYIntList.Clear();
aYIntList.AddRange(intList3);

Console.WriteLine(aYIntList[3]);
Here's the question : is there any other way than using 'Clear() and then 'AddRange
to replace the "virtual inner list" <T> "embodied" via inheritance in the class ?

1. you cannot assign to an instance of the class : aYIntList = intList3;

You get this error : "Error Cannot implicitly convert type
'System.Collections.Generic.List<int>' to
'WindowsFormsApplication1.anyDamnList<int>'. An explicit conversion
exists (are you missing a cast?_

2. you can't cast like this : aYIntList = (anyDamnList<int>) intList3
: that will NOT give you a compile time error but at run-time you get
: ""Unable to cast object of type
'System.Collections.Generic.List`1[System.Int32]' to type
'WindowsFormsApplication1.anyDamnList`1[System.Int32]'."}

3. I played around with Linq's OfType<> and Cast<> operators

aYIntList = intList3.OfType<int>();
aYIntList = intList3.Cast<int>();

Both of those will throw compile time errors like so : "Cannot
implicitly convert type 'System.Collections.Generic.IEnumerable<int>'
to 'WindowsFormsApplication1.anyDamnList<int>'. An explicit conversion
exists (are you missing a cast?)"

"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

AnswerRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? [modified] Pin
PIEBALDconsult12-Dec-09 3:45
mvePIEBALDconsult12-Dec-09 3:45 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff12-Dec-09 7:07
professionalBillWoodruff12-Dec-09 7:07 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
PIEBALDconsult12-Dec-09 7:42
mvePIEBALDconsult12-Dec-09 7:42 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff12-Dec-09 8:09
professionalBillWoodruff12-Dec-09 8:09 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
PIEBALDconsult12-Dec-09 9:49
mvePIEBALDconsult12-Dec-09 9:49 
AnswerRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
DaveyM6912-Dec-09 7:44
professionalDaveyM6912-Dec-09 7:44 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff12-Dec-09 8:30
professionalBillWoodruff12-Dec-09 8:30 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
PIEBALDconsult12-Dec-09 9:06
mvePIEBALDconsult12-Dec-09 9:06 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
Gideon Engelberth12-Dec-09 10:56
Gideon Engelberth12-Dec-09 10:56 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff13-Dec-09 12:28
professionalBillWoodruff13-Dec-09 12:28 
AnswerRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
Nicholas Butler12-Dec-09 23:28
sitebuilderNicholas Butler12-Dec-09 23:28 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff13-Dec-09 12:21
professionalBillWoodruff13-Dec-09 12:21 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
Nicholas Butler13-Dec-09 22:45
sitebuilderNicholas Butler13-Dec-09 22:45 
GeneralRe: Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? [modified] Pin
BillWoodruff14-Dec-09 4:50
professionalBillWoodruff14-Dec-09 4:50 
Answera "partial solution" to : re : Replace "inner list" of a generic class inheriting from List&lt;T&gt; ? Pin
BillWoodruff13-Dec-09 12:51
professionalBillWoodruff13-Dec-09 12:51 
QuestionUsing Methods within a Switch Case Pin
DevonDaDude11-Dec-09 22:47
DevonDaDude11-Dec-09 22:47 
AnswerRe: Using Methods within a Switch Case Pin
Abhinav S11-Dec-09 22:56
Abhinav S11-Dec-09 22:56 

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.