-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathArrays.cs
More file actions
52 lines (40 loc) · 863 Bytes
/
Arrays.cs
File metadata and controls
52 lines (40 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//This solution uses Arrays concept--Difference between Arrays and Hashtable
using System;
using System.Collections.Generic;
public class ArtistSalesData
{
public string Artist {get;set;}
public double Sales {get;set;}
}
public class Program
{
public static void Main()
{
Program p=new Program();
double sd=p.Salesdata("Amanda");
Console.WriteLine(sd);
}
public double Salesdata(string Name)
{
double sales=0;
ArtistSalesData[] sd=new ArtistSalesData[50];
sd[0]=new ArtistSalesData();
sd[0].Artist="Amanda";
sd[0].Sales=34.3;
sd[1]=new ArtistSalesData();
sd[1].Artist="Bosh";
sd[1].Sales=39.3;
sd[2]=new ArtistSalesData();
sd[2].Artist="Christine";
sd[2].Sales=60;
foreach( ArtistSalesData ad in sd)
{
if(ad==null) continue;
if(ad.Artist==Name)
{
sales=ad.Sales;
}
}
return sales;
}
}