Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have two arrays
C#
input1 = new string[4] { "A", " B", " C", " D" };

and
C#
input2 = new int[6] { 2, 3, 1, 5, 4, 3 };

now i want like this
{A,B}=2,{A,C}=3,{A,D}=1<br />
{B,C}=5,{B,D}=4,{C,D}=3


C#
public static void minimum_cost(out string[] input1, out int[] input2)
        {

            input1 = new string[4] { "A", " B", " C", " D" };
            input2 = new int[6] { 2, 3, 1, 5, 4, 3 };
              int i = 0;
            int j = 0;
            var query = from s in input1
                        let num = i++
                        group s by num / 2 into g
                        select g.ToArray();
            var results = query.ToArray();

            var query2 = from s1 in input2
                        let num1 = j++
                        group s1 by num1 / 1 into g1
                        select g1.ToArray();
            var results2 = query.ToArray();
            foreach (string[] r1 in results)
            {
                Console.WriteLine("{0}",r1);
            }
            foreach (string[] r2 in results2)
            {
                Console.WriteLine("{0}", r2);
            } 
    
         
        }   

i was try this i didn't get it
Posted
Updated 14-Apr-13 20:47pm
v4
Comments
Naz_Firdouse 15-Apr-13 1:49am    
what have you tried? where you struck?
amperayani 15-Apr-13 2:08am    
public static void minimum_cost(out string[] input1, out int[] input2)
{

input1 = new string[4] { "A", " B", " C", " D" };
input2 = new int[6] { 2, 3, 1, 5, 4, 3 };
int i = 0;
int j = 0;
var query = from s in input1
let num = i++
group s by num / 2 into g
select g.ToArray();
var results = query.ToArray();

var query2 = from s1 in input2
let num1 = j++
group s1 by num1 / 1 into g1
select g1.ToArray();
var results2 = query.ToArray();
foreach (string[] r1 in results)
{
Console.WriteLine("{0}",r1);
}
foreach (string[] r2 in results2)
{
Console.WriteLine("{0}", r2);
}


}
i was try this i didn't get it
Maciej Los 15-Apr-13 2:29am    
Next time, use "Improve question" widget, OK?
Sergey Alexandrovich Kryukov 15-Apr-13 2:24am    
Not clear. Your formulation of the problem is insufficient. Use "Improve question".
—SA
johannesnestler 15-Apr-13 9:12am    
I don't understand what you want, can you please improve/explain the phrase: "now I want it like this".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900