CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2011
    Posts
    73

    [RESOLVED] Different Type of Fuction Call - Convert From C#

    Hi, I have a small project in c# to Paste from ClipBoard to DataGridview. In that areas, I need to convert the below
    codes, which is very confusion..
    Code:
            private Dictionary<int, Dictionary<int, string>> ClipBoardValues(string clipboardValue)
            {
                Dictionary<int, Dictionary<int, string>>
                copyValues = new Dictionary<int, Dictionary<int, string>>();
    
                String[] lines = clipboardValue.Split('\n');
    
                for (int i = 0; i <= lines.Length - 1; i++)
                {
                    copyValues[i] = new Dictionary<int, string>();
                    String[] lineContent = lines[i].Split('\t');
    
                    //if an empty cell value copied, then set the dictionary with an empty string
                    //else Set value to dictionary
                    if (lineContent.Length == 0)
                        copyValues[i][0] = string.Empty;
                    else
                    {
                        for (int j = 0; j <= lineContent.Length - 1; j++)
                            copyValues[i][j] = lineContent[j];
                    }
                }
                return copyValues;
            }
    Thanks for the helps
    Thanks Again

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Different Type of Fuction Call - Convert From C#

    And where, specifically, lies the problem? To me that function doesn't really look any spectacular (at first sight).
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Dec 2011
    Posts
    73

    Re: Different Type of Fuction Call - Convert From C#

    Hi Eri, Thanks for your reply. I get confused to convert the below three lines only
    Code:
    private Dictionary<int, Dictionary<int, string>> ClipBoardValues(string clipboardValue)
            {
                Dictionary<int, Dictionary<int, string>>
                copyValues = new Dictionary<int, Dictionary<int, string>>();
    }
    Again & Again Thousands of thanks for your guidances...

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Different Type of Fuction Call - Convert From C#

    There's still no type alias for System::String in C++/CLI and declaring variables of reference types requires the ^ to denote a tracking handle, as opposed to a value type instance. (You seemed to already have noticed these in http://forums.codeguru.com/showthrea...15#post2153515). These type syntax rules apply to generic type parameters as well. And you need gcnew to instantiate reference types instead of new. Hence:

    Code:
    private:
      Dictionary<int, Dictionary<int, String ^> ^> ^ClipBoardValues(String ^clipboardValue)
      {
        Dictionary<int, Dictionary<int, String ^> ^> ^copyValues = gcnew Dictionary<int, Dictionary<int, String ^> ^>;
    
        // ...
      }
    (Assuming this is inline-defined inside a class body and you've got using namespace directives for System and System::Collections::Generic.)

    (Not compiled, let alone tested, may contain plain typos and careless omissions.)
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Dec 2011
    Posts
    73

    Re: Different Type of Fuction Call - Convert From C#

    Thank Eri, I get clear.....All your replies are very nice...
    Thanks Again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured