Convert Row data to columns in MVC - asp.net-mvc

I have data in my List like below
Click Here
I want to convert that data like this Click Here and also Same project should be in same color.
is it possible to do it through coding? Can anybody help me I have no idea how to get the expected output. I'm using MVC Linq and Entity Framework.

of course you must write custom code
for (int i = 0; i < rows; i++)
{
// Weeks of the month
for (int j = 0; j < 5; j++)
{
// ToDo build another collection
}
}

Related

How do I know the content of my 2-D array in MQL4?

I have got an array, s[7][7], I read using a ReadFileString() a CSV file into it, the CSV file contained a set of numbers.
I'm looking for numbers greater than 85, stored in the 2-D array, and the column and row the number/element belongs to.
In order to get content of the array just loop it over:
int value = 85;
for(int i=0; i<ArrayRange(s,0); i++){
for(int j=0; j<ArrayRange(s,1); j++){
if (StrToInteger(s[i][j])>value){
// here you have i and j indexes of array
}
}
}
Of course you can have int array[][] instead of string-s for faster work, use StrToInteger() with ReadFileString() for that.

Call objects by their string name where the strings are built dynamically [duplicate]

This question already has answers here:
Objective C Equivalent of PHP's "Variable Variables" [duplicate]
(2 answers)
Closed 8 years ago.
For my iOS app, I created a class named Tile which is a subclass of UIImageView.
The tiles are displayed in a kind of an array of 6 rows and 5 column.
I previously created 30 instances of my Tile class. These instances are all named this way: RiCj where i is the row number and j is the column number.
I would like to create a for loop where I would apply a specific treatment to each of my tiles (basically, I want to display the tiles where displayTile is an instance method of the class Tile).
I would love to do something like (I know the code below is incorrect):
for (int i = 1; i <= numberOfRows ; j++) {
for (int j = 1; j <= numberOfColumns ; j++) {
[self.RiCj displayTile];
}
}
I don't know how to do a call to my tiles based on their dynamic string title.
Yes, technically, it is possible - you may use Key-Value Coding like this:
for (int i = 1; i <= numberOfRows; i++) {
for (int j = 1; j <= numberOfColumns; j++) {
NSString* tileName = [NSString stringWithFormat:#"R%dC%d", i, j];
[[self valueForKey:tileName] displayTile];
}
}
But you should not. It won't be a clean solution. Array is a more natural choice here.
Yes, you can actually access a property of a class dynamically by creating a string naming the property then using KVC like so:
NSString *propertyName = [NSString stringWithFormat:#"R%dC%d", i, j];
tile = [self valueForKey:propertyName];
But should you? No, not in this case. It's a horrible hack when the perfectly nice alternative of making an array (or array of arrays) is available.
Here's what array of array creation and access might look like (by using handy Objective C literals for arrays):
NSArray *tiles = #[
#[ tile0C0, tile0C1, tile0C2 ],
#[ tile1C0, tile1C1, tile1C2 ],
#[ tile2C0, tile2C1, tile2C2 ],
];
for (int i = 0; i < numberOfRows ; j++) {
for (int j = 0; j < numberOfColumns ; j++) {
tile = tiles[j][i];
// do stuff with tile
}
}
If I understand correctly, you're trying to access the instances by their variable names dynamically. You can't do that, as your variable name is designed for you, the programmer, and is not available at runtime.
What you can do, however, is to keep a list of your created instances in an array somewhere, and simply iterate over that array when you need to access them.
Alternatively, if you created the 30 tiles as 30 different properties, you could use some dynamic code to get them. At that point, however, I would strongly recommend to use the array technique.

how to add a new linkedlist element into arraylist

Im new at Kava, and Im having a trouble to understand what am I doing wrong, and why my code isnt working.
Im trying to implement the bucket sort, using a given array of doubles (double[] ar),
and using arrayList of linkedLists.
here is my code:
int n = ar.length;
//initializing the buckets
ArrayList<LinkedList<Double>> buckets = new ArrayList<LinkedList<Double>>(ar.length);
// Initialize 'n' buckets (each is a LinkedList<Double>) (B[0..n-1])
for (int i = 0; i < n -1; i++) {
buckets.add(i, new LinkedList<Double>());
}
for (int i = 0; i < n; i++) {
buckets.add((int)(n*ar[i]), ar[i]);
}
it
shows an error on "add", and it says:
"The method add(int, LinkedList) in the type ArrayList> is not applicable for the arguments (int, double)"
Thanks.
ArrayList<LinkedList<Double>> buckets[] is your Array of ArrayList OF LinkedList Of DOUBLE.
You are addind a DOUBLE to your ArrayList insted of a LinkedList when doing :
buckets[(int)(n * ar[i])].add((Double)ar[i]);
Consider changing your buckets declaration
Maybe what you wanted is
"ArrayList<Double> buckets[]"
But careful the instanciation changes to
buckets[index] = new ArrayList<Double>();

Comparing objects of NSArray1 to NSArray2 [duplicate]

This question already has answers here:
Finding out NSArray/NSMutableArray changes' indices
(3 answers)
Closed 8 years ago.
Here is what i need it to do.
NSArray has 10 objects
NSArray2 has the same 10 objects but in different indexes.
I need to compare if NSArray1 index:5 matches NSArray2 index:5 if not tell me if the object has moved up or down in the NSArray2, same for every other object inside that array.
The objects have the following properties: id and name.
Any suggestion on how i can accomplish this?
If you have RAM to spare you could build a map from the object's id to its index in array 1, then scan array 2 and compare, like:
NSMutableDictionary *map = [[NSMutableDictionary alloc] init];
for (NSUInteger j = 0; j < array1.count; j++) {
id object = array1[j];
map[object.id] = #(j);
}
for (NSUInteger j = 0; j < array2.count; j++) {
id object = array2[j];
id identifier = object.id;
NSUInteger array1Index = [map[identifier] unsignedIntegerValue];
// Compare array1Index to j here.
}
That'll let you compare with a running time that grows like the number of objects in the arrays, but note that you have to spend some extra RAM to make that map. You could compare with only constant RAM costs if you're willing to spend more time:
for (NSUInteger j = 0; j < array1.count; j++) {
id object = array1[j];
NSUInteger k = [array2 indexOfObject:object];
// Compare j and k, note that k could be NSNotFound.
}
And that should have a running time that grows like the product of the array counts.

how to include index number in a class name

I am making a program where I need to loop through an array with a list of letters. I want the letters to be shown on their specific label. I have therefore created an outlet of each (about 38) and given them the name "alif01", "alif02", etc.
for (int i = 0; i < [arabicLetters count]; i++) {
int num = i;
NSString *letterString = [arabicLetters objectAtIndex:i];
NSLog(#"alif0%d is %#", num, letterString);
alif0**[i]**.text = arabicLetters[i];
}
is it possible to use the index [i] instead of writing it all manually?
You should not have 38 IBOutlet properties for this. You should have an array (possibly an IBOutletCollection) so that you can loop over the array / index into the array.
While technically you can create a key name and use KVC valueForKey: (appending strings / string format), the array approach is a much better solution.
Indeed, as you already have a loop, you would be better served by creating the labels in the loop directly, then you know you have the correct number. This is particularly beneficial later, when you change the contents of arabicLetters (though that sounds like it isn't a concern in this particular case).
Try with below code:
for (int i = 0; i < [arabicLetters count]; i++) {
NSString *letterString = [arabicLetters objectAtIndex:i];
NSString *propertyName = [NSString stringWithFormat:#"alif0%d.text",i];
[self setValue:letterString forKeyPath:propertyName];
}

Resources