1 00:00:00,360 --> 00:00:03,760 We've got more data in our CSV file we need to add properties for 2 00:00:03,760 --> 00:00:05,480 in our GameResult class. 3 00:00:05,480 --> 00:00:07,587 Let's check out our CSV file. 4 00:00:07,587 --> 00:00:11,760 Looks like the next four fields are Goals, GoalAttempts, 5 00:00:11,760 --> 00:00:14,270 ShotsOnGoal, and ShotsOffGoal. 6 00:00:16,270 --> 00:00:18,830 They all seem to be positive whole numbers. 7 00:00:21,470 --> 00:00:25,430 Let's talk a little more about the different integral types in C#. 8 00:00:25,430 --> 00:00:27,560 You've seen bytes and integers. 9 00:00:27,560 --> 00:00:30,480 All of the integral types we'll be covering here have a signed and 10 00:00:30,480 --> 00:00:32,440 an unsigned version. 11 00:00:32,440 --> 00:00:33,560 Let's recap. 12 00:00:33,560 --> 00:00:36,450 A byte is an 8-bit unsigned integer. 13 00:00:36,450 --> 00:00:39,820 It can store values from 0 to 255. 14 00:00:39,820 --> 00:00:45,787 The signed byte, SByte, can hold values from -128 to 127. 15 00:00:45,787 --> 00:00:47,002 It's very common and 16 00:00:47,002 --> 00:00:52,080 usually recommended to just use the int keyword when creating integers. 17 00:00:52,080 --> 00:00:55,450 The int keyword represents a signed 32-bit integer, 18 00:00:55,450 --> 00:01:00,270 which, if you remember, can store both negative and positive values. 19 00:01:00,270 --> 00:01:03,920 It has a pretty big range from around -2 billion to 2 billion. 20 00:01:05,260 --> 00:01:10,120 We can demystify these seemingly arbitrary minimums and maximums a little bit. 21 00:01:10,120 --> 00:01:16,361 Our byte type is 8-bit, it can store values from 0 to 255. 22 00:01:16,361 --> 00:01:21,340 2 to the 8 power is 256, which is the number of values a byte can store. 23 00:01:22,400 --> 00:01:26,930 Our int type or Int32 is a 32-bit integer. 24 00:01:26,930 --> 00:01:31,958 So, it can store a number of values that is equal to 2 to the 32nd power, 25 00:01:31,958 --> 00:01:33,997 which is a pretty big number. 26 00:01:33,997 --> 00:01:38,643 I'm going to use the interactive window here 27 00:01:38,643 --> 00:01:43,540 like a calculator, Math.Pow(2,32). 28 00:01:46,000 --> 00:01:49,698 Since the int keyword represents a 32-bit signed integer, 29 00:01:49,698 --> 00:01:53,080 it has both negative and positive values. 30 00:01:53,080 --> 00:01:56,520 It can represent around 4 billion different values. 31 00:01:56,520 --> 00:02:01,161 Luckily for us, if we really need to know without looking it up, the int type has 32 00:02:01,161 --> 00:02:05,133 a static property on it that tells us the min value and the max value. 33 00:02:05,133 --> 00:02:09,808 int.MinValue and int.MaxValue, 34 00:02:09,808 --> 00:02:16,749 the unsigned version of a 32-bit integer is a uint. 35 00:02:16,749 --> 00:02:19,170 The u stands for unsigned. 36 00:02:19,170 --> 00:02:22,675 It only holds positive values and 37 00:02:22,675 --> 00:02:27,681 goes up to the 4 billion number we saw earlier, 38 00:02:27,681 --> 00:02:31,701 uint.MinValue, uint.MaxValue. 39 00:02:31,701 --> 00:02:37,540 The least common of the integer types is a short, it's a 16-bit unsigned integer. 40 00:02:37,540 --> 00:02:42,900 So it can store 2 to the 16th number of values, which is around 65,000. 41 00:02:42,900 --> 00:02:47,949 short.Min and short.MaxValue, 42 00:02:47,949 --> 00:02:53,839 and its unsigned counterpart, ushort, 43 00:02:53,839 --> 00:02:59,930 ushort.MinValue, ushort.MaxValue. 44 00:02:59,930 --> 00:03:01,880 You might see them, you might not. 45 00:03:01,880 --> 00:03:05,800 If you consider using a short type, I'd probably just go with an int. 46 00:03:05,800 --> 00:03:09,600 But if you happen to need an integer that can hold more than 4 billion possible 47 00:03:09,600 --> 00:03:15,978 values, that's where the long type comes in, long.MinValue, 48 00:03:15,978 --> 00:03:19,290 long.MaxValue. 49 00:03:19,290 --> 00:03:22,340 It can come in handy for really big numbers. 50 00:03:22,340 --> 00:03:25,295 You'll see it in the .Net framework pretty often. 51 00:03:25,295 --> 00:03:28,441 I can think of a property that uses the long type. 52 00:03:28,441 --> 00:03:33,034 You saw DateTime earlier, it has a property on it called ticks. 53 00:03:33,034 --> 00:03:41,650 DateTime.Now.Ticks, ticks are 1/10,000 of a millisecond. 54 00:03:41,650 --> 00:03:45,210 So, it has the potential to be a really big number. 55 00:03:45,210 --> 00:03:51,241 It also has an unsigned version, the ulong, 56 00:03:51,241 --> 00:03:56,660 ulong.MinValue, ulong.MaxValue. 57 00:03:56,660 --> 00:04:00,240 I've linked to an MSTN article that lists all the integral types and 58 00:04:00,240 --> 00:04:02,400 their values for reference. 59 00:04:02,400 --> 00:04:03,560 For most purposes, 60 00:04:03,560 --> 00:04:09,210 using the int keyword to specify a 32-bit signed integer is the way to go. 61 00:04:09,210 --> 00:04:11,593 So let's do that in our GameResult class, 62 00:04:15,645 --> 00:04:21,919 public int Goals { get; set; }, 63 00:04:21,919 --> 00:04:26,938 and public int GoalAttempts 64 00:04:26,938 --> 00:04:30,911 { get; set; }, and 65 00:04:30,911 --> 00:04:36,558 public int ShotsOnGoal { get; 66 00:04:36,558 --> 00:04:41,575 set; }, and the last one, 67 00:04:41,575 --> 00:04:49,330 public int ShotsOffGoal { get; set; }. 68 00:04:51,409 --> 00:04:55,280 So now we need to parse these values from our CSV file. 69 00:04:55,280 --> 00:04:57,970 We can use that with the int.tryParse method. 70 00:04:59,470 --> 00:05:05,264 We can even use the same variable for the L parameter as we try to parse each one. 71 00:05:05,264 --> 00:05:13,928 Let's see, int parseInt and 72 00:05:13,928 --> 00:05:21,420 if (int.TryParse(values[3], 73 00:05:21,420 --> 00:05:27,549 out parseInt)), then we'll 74 00:05:27,549 --> 00:05:35,500 assign gameResult.Goals = parseInt. 75 00:05:37,850 --> 00:05:39,670 And let's do a little copy paste magic. 76 00:05:42,040 --> 00:05:47,815 We've got four properties, so one, two, three more. 77 00:05:47,815 --> 00:05:54,160 Then we'll change values 4, 5, and 6. 78 00:05:55,810 --> 00:06:02,963 This is gonna be GoalAttempts and 79 00:06:02,963 --> 00:06:06,539 ShotsOnGoal and 80 00:06:06,539 --> 00:06:11,141 then ShotsOffGoal. 81 00:06:11,141 --> 00:06:12,760 Let's take a look at our progress. 82 00:06:13,860 --> 00:06:17,153 We still got our breakpoints, so we'll debug with F5. 83 00:06:23,704 --> 00:06:25,590 All right, things are coming along nicely.