Click here to Skip to main content
15,887,928 members
Home / Discussions / C#
   

C#

 
QuestionSentimental analysis and plotting charts with C# Pin
sachidanandgowda20-Nov-14 21:54
sachidanandgowda20-Nov-14 21:54 
QuestionRe: Sentimental analysis and plotting charts with C# Pin
Richard MacCutchan20-Nov-14 23:21
mveRichard MacCutchan20-Nov-14 23:21 
AnswerRe: Sentimental analysis and plotting charts with C# Pin
Mycroft Holmes20-Nov-14 23:31
professionalMycroft Holmes20-Nov-14 23:31 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
Richard MacCutchan20-Nov-14 23:57
mveRichard MacCutchan20-Nov-14 23:57 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
BillWoodruff21-Nov-14 9:35
professionalBillWoodruff21-Nov-14 9:35 
GeneralRe: Sentimental analysis and plotting charts with C# Pin
Mycroft Holmes21-Nov-14 13:10
professionalMycroft Holmes21-Nov-14 13:10 
AnswerRe: Sentimental analysis and plotting charts with C# Pin
BillWoodruff21-Nov-14 9:40
professionalBillWoodruff21-Nov-14 9:40 
GeneralI want to know whether mycode is right Pin
fengyuchun8820-Nov-14 16:45
fengyuchun8820-Nov-14 16:45 
which person can tell me whether the method I used is correct? If not, please tell me what I should do.

i write a code that can convert cross table to vertical table

cross table :



=====================
Name,Sex,City
=====================
jason,male,hk
---------------------
vivia,Female,dk
---------------------

vertical table


=====================
Name,jason,vivia
=====================
Sex,male,Female
---------------------
City,hk,dk
---------------------


C#
public static DataTable ConvertDataTable(DataTable source)
{
    try
    {
        DataTable _dtResult = new DataTable(source.TableName, source.Namespace);

        for (int i = 0; i < source.Columns.Count; i++)
        {
            List<string> _lstItems = new List<string>();

            if (i == 0)
            {
                _dtResult.Columns.Add(source.Columns[i].ColumnName);
            }
            else
            {
                _lstItems.Add(source.Columns[i].ColumnName);
            }

            for (int ii = 0; ii < source.Rows.Count; ii++)
            {
                if (i == 0)
                {
                    _dtResult.Columns.Add(source.Rows[ii][i].ToString());
                }
                else
                {
                    _lstItems.Add(source.Rows[ii][i].ToString());
                }
            }

            if (_lstItems.Count > 0)
            {
                _dtResult.Rows.Add(_lstItems.ToArray());
            }

        }

        return _dtResult;
    }
    catch
    {
        return source;
    }

}

QuestionRe: I want to know whether mycode is right Pin
Richard MacCutchan20-Nov-14 21:51
mveRichard MacCutchan20-Nov-14 21:51 
QuestionWPF Controls Binding to Object doesn't work Pin
jerryeagle20-Nov-14 11:34
jerryeagle20-Nov-14 11:34 
AnswerRe: WPF Controls Binding to Object doesn't work Pin
Richard MacCutchan20-Nov-14 21:49
mveRichard MacCutchan20-Nov-14 21:49 
QuestionAutomated fetch of data from SQL database using C# Pin
Member 1113303420-Nov-14 9:06
Member 1113303420-Nov-14 9:06 
AnswerRe: Automated fetch of data from SQL database using C# Pin
Mycroft Holmes20-Nov-14 11:44
professionalMycroft Holmes20-Nov-14 11:44 
Questionhow to pass values to different master page in asp.net? Pin
iamvinod3420-Nov-14 5:07
iamvinod3420-Nov-14 5:07 
Questionhow to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 0:49
RahulAhire2620-Nov-14 0:49 
AnswerRe: how to solve error related to the PInvoke Stack Imbalance Pin
Pete O'Hanlon20-Nov-14 1:00
mvePete O'Hanlon20-Nov-14 1:00 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 1:57
RahulAhire2620-Nov-14 1:57 
AnswerRe: how to solve error related to the PInvoke Stack Imbalance Pin
OriginalGriff20-Nov-14 2:30
mveOriginalGriff20-Nov-14 2:30 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
RahulAhire2620-Nov-14 2:00
RahulAhire2620-Nov-14 2:00 
GeneralRe: how to solve error related to the PInvoke Stack Imbalance Pin
Richard MacCutchan20-Nov-14 2:32
mveRichard MacCutchan20-Nov-14 2:32 
QuestionC sharp design principle Pin
Sarita S19-Nov-14 19:08
Sarita S19-Nov-14 19:08 
AnswerRe: C sharp design principle Pin
Pete O'Hanlon19-Nov-14 21:09
mvePete O'Hanlon19-Nov-14 21:09 
GeneralRe: C sharp design principle Pin
Sarita S20-Nov-14 0:05
Sarita S20-Nov-14 0:05 
GeneralRe: C sharp design principle Pin
Pete O'Hanlon20-Nov-14 0:34
mvePete O'Hanlon20-Nov-14 0:34 
AnswerRe: C sharp design principle Pin
V.20-Nov-14 3:43
professionalV.20-Nov-14 3:43 

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.