Click here to Skip to main content
15,922,015 members
Home / Discussions / C#
   

C#

 
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 
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 
With the help of a workmate, I've resolved the issue. The quirk was in the Add method of the DataColumnCollection class (which holds the cells for the rows). The writers of the method, in their infinite wisdom, convert the input value to a string before adding it. This is default behaviour. It can be overridden by creating a custom DataColumn to hold the type of the input data. I'm including the code which now works.

using System;<br />
using System.Data;<br />
using System.Collections;<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 />
        DataColumn dC = new DataColumn(COL, list.GetType());<br />
        table.Columns.Add(dC);<br />
        DataRow row = table.NewRow();<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 type: " + resultObj.GetType());        <br />
        ArrayList resultList = (ArrayList) resultObj;        <br />
        string resultStr = (string)resultList[0];<br />
        Console.WriteLine(resultStr);<br />
    }<br />
}


I guess I should be reading the documentation more closely so that I would be more aware of "features" like this Wink | ;)

Thanks for the replies. Regards,
Michael
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 
AnswerRe: RichTextBox not display the right string? Pin
leppie22-Apr-05 6:42
leppie22-Apr-05 6:42 
GeneralReg Ex Pin
mvermef21-Apr-05 13:00
mvermef21-Apr-05 13:00 

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.