Click here to Skip to main content
15,898,787 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to play repeadly the media file in full screen mode Pin
Christian Graus21-Apr-05 19:23
protectorChristian Graus21-Apr-05 19:23 
GeneralRe: How to play repeadly the media file in full screen mode Pin
Lalit N Dubey21-Apr-05 23:17
Lalit N Dubey21-Apr-05 23:17 
GeneralRe: How to play repeadly the media file in full screen mode Pin
Christian in a nice hotel in Singapore24-Apr-05 0:23
sussChristian in a nice hotel in Singapore24-Apr-05 0:23 
GeneralCasting multi dimensional arrays Pin
Esmo200021-Apr-05 19:14
Esmo200021-Apr-05 19:14 
GeneralRe: Casting multi dimensional arrays Pin
Christian Graus21-Apr-05 19:23
protectorChristian Graus21-Apr-05 19:23 
GeneralRe: Casting multi dimensional arrays Pin
Esmo200022-Apr-05 1:41
Esmo200022-Apr-05 1:41 
GeneralRe: Casting multi dimensional arrays Pin
S. Senthil Kumar22-Apr-05 2:44
S. Senthil Kumar22-Apr-05 2:44 
GeneralWeird class cast issue Pin
serious-sam21-Apr-05 17:18
serious-sam21-Apr-05 17:18 
Hi all,

I'm having a problem using class casts. I'm storing an ArrayList inside a DataTable, and when I want to retrieve the list, I get an InvalidCastException. Here is my code:

using System;<br />
using System.Data;<br />
using System.Collections;<br />
<br />
class CastTest {<br />
    const string COL = "test";<br />
    static void Main() {<br />
        Console.WriteLine("CastTest");<br />
        ArrayList list = new ArrayList();<br />
        string str = "Hello world";<br />
        list.Add(str);        <br />
        Console.WriteLine("arrayList created");        <br />
        DataTable table = new DataTable();<br />
        DataRow row = table.NewRow();<br />
        table.Columns.Add(COL);<br />
        table.Rows.Add(row);<br />
        row[COL] = list;                <br />
        Console.WriteLine("table created");        <br />
        object resultObj = table.Rows[0][COL];        <br />
        Console.WriteLine("resultObj: " + resultObj);        <br />
        ArrayList resultList = (ArrayList)resultObj;        <br />
        string resultStr = (string)resultList[0];<br />
        Console.WriteLine(resultStr);<br />
    }<br />
}


The second last WriteLine statement prints: "resultObj: System.Collections.ArrayList". I seem to be retrieving the ArrayList as an object, but I'm unable to cast it. Why?

Thanks in advance.
Cheers,
Michael
GeneralRe: Weird class cast issue Pin
Christian Graus21-Apr-05 17:38
protectorChristian Graus21-Apr-05 17:38 
GeneralRe: Weird class cast issue Pin
serious-sam21-Apr-05 17:51
serious-sam21-Apr-05 17:51 
QuestionHow to Escape the &quot;;&quot; Pin
CSharpBala21-Apr-05 17:14
CSharpBala21-Apr-05 17:14 
AnswerRe: How to Escape the ";" Pin
Ashok Dhamija21-Apr-05 18:05
Ashok Dhamija21-Apr-05 18:05 
AnswerRe: How to Escape the &quot;;&quot; Pin
leppie21-Apr-05 19:42
leppie21-Apr-05 19:42 
Generalconnection.close or .dispose Pin
vcllvc21-Apr-05 16:54
vcllvc21-Apr-05 16:54 
GeneralRe: connection.close or .dispose Pin
Christian Graus21-Apr-05 18:14
protectorChristian Graus21-Apr-05 18:14 
GeneralRe: connection.close or .dispose Pin
Dave Kreskowiak22-Apr-05 1:14
mveDave Kreskowiak22-Apr-05 1:14 
GeneralRe: connection.close or .dispose Pin
S. Senthil Kumar22-Apr-05 3:02
S. Senthil Kumar22-Apr-05 3:02 
GeneralRe: connection.close or .dispose Pin
Dave Kreskowiak22-Apr-05 5:26
mveDave Kreskowiak22-Apr-05 5:26 
GeneralRe: connection.close or .dispose Pin
vcllvc22-Apr-05 17:20
vcllvc22-Apr-05 17:20 
GeneralRe: connection.close or .dispose Pin
S. Senthil Kumar22-Apr-05 18:19
S. Senthil Kumar22-Apr-05 18:19 
QuestionRichTextBox not display the right string? Pin
Snowjim21-Apr-05 14:01
Snowjim21-Apr-05 14:01 
AnswerRe: RichTextBox not display the right string? Pin
Hawk33721-Apr-05 15:30
Hawk33721-Apr-05 15:30 
GeneralRe: RichTextBox not display the right string? Pin
Snowjim21-Apr-05 22:36
Snowjim21-Apr-05 22:36 
GeneralRe: RichTextBox not display the right string? Pin
Snowjim22-Apr-05 4:00
Snowjim22-Apr-05 4:00 
GeneralRe: RichTextBox not display the right string? Pin
Snowjim22-Apr-05 4:11
Snowjim22-Apr-05 4:11 

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.