How to write this in C #. NET?

Last post 09-12-2009 7:46 PM by nijhawan.saurabh. 6 replies.

Sort Posts:

  • How to write this in C #. NET?

    09-05-2009, 12:41 PM
    • Member
      3 point Member
    • sv88erik
    • Member since 06-28-2009, 3:08 PM
    • Norway
    • Posts 15

    Can someone be kind enough to write this into c#?



    for($i = 0;$i <= 10;$i++) {
    
    	$array[$i]["key"] = rand(1,10);
    	$array[$i]["value"] = "value" . rand(1,10);
    
    }
    
    echo "----- UTPUTT ---------<br />";
    echo "<strong>Random:</strong>" . $array[rand(0,9)]["value"] " . "<br />";
    echo "<strong>value 4:</string>" . $array[4]["value"];



    Has now gone over to the ASP and C #. NET
    (x)PHP developer for 8 year.
  • Re: How to write this in C #. NET?

    09-05-2009, 2:32 PM

    view plaincopy to clipboardprint?

    Random rand= new Random();
    1. for(i = 0;i <= 10;i++) {  
    2.   
    3.     array1[i]= rand.Next();
    4.    
    5.   
    6. }  
    7.   

    Now you got to mention you want the code for a web application, console , or a windows application?



    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy


  • Re: How to write this in C #. NET?

    09-06-2009, 3:08 PM
    • Member
      3 point Member
    • sv88erik
    • Member since 06-28-2009, 3:08 PM
    • Norway
    • Posts 15
    It is for the web.
    But should not the variable first with the data type in. NET?

    And there is no way to use the Dictionary for this?
    Has now gone over to the ASP and C #. NET
    (x)PHP developer for 8 year.
  • Re: How to write this in C #. NET?

    09-06-2009, 3:23 PM



    Random rand= new Random();// this is the declaration for rand
    1. for(int i = 0;i <= 10;i++) {  
    2.   
    3.     array1[i]= rand.Next();
    4.    
    5.   
    6. }  
    7.   
    8. Response.Write("Hello");//For writing data on the web.You would actually have a label or something and write text to it.




    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy


  • Re: How to write this in C #. NET?

    09-06-2009, 3:40 PM
    • Member
      3 point Member
    • sv88erik
    • Member since 06-28-2009, 3:08 PM
    • Norway
    • Posts 15

    If you look at my example, so you can see I have an array outside of the first ...:)
    That's what I wonder, how to do it. While one can use the first array as an id?


    Has now gone over to the ASP and C #. NET
    (x)PHP developer for 8 year.
  • Re: How to write this in C #. NET?

    09-07-2009, 10:20 AM
    • Member
      3 point Member
    • sv88erik
    • Member since 06-28-2009, 3:08 PM
    • Norway
    • Posts 15

    bump

    Has now gone over to the ASP and C #. NET
    (x)PHP developer for 8 year.
  • Re: How to write this in C #. NET?

    09-12-2009, 7:46 PM

    Hi,

    Therer is dictionary type in C# as well.

    http://weblogs.asp.net/justin_rogers/pages/124403.aspx

    Please read the following post.


    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy


Page 1 of 1 (7 items)