✅ Homework Help

https://i.gyazo.com/f23d758d46581bcfb84f88d4178cd484.png What should I return from the FillArray() method? It would make a lot more since if I was returning an array, if the return type was an int[], but the return type is an int, therefore it should just be returning single ints. I am not sure how it is supposed to work given I am putting the entire array into FillArray() and then it's just supposed to return a single int, which I assume is the individual element. Any help would be welcome.
8 Replies
cptcrawler
cptcrawler2y ago
i mean the array itself dervives from Array<T> so it's actually a reference type. you just may want to operate directly on the int[] array param itself and it will reflected to the passed arg
cptcrawler
cptcrawler2y ago
Stack Overflow
Reference type vs value type
I'm reading about structs and classes in C# and to my understanding structs are value types and classes are reference types. But I'm a little confused about how class objects behave when they are p...
cptcrawler
cptcrawler2y ago
then for the return you just may need to return the length of the array as the response template requirement suggest i read the homework better and before i understood you question wrongly , hope that helps anyway
jcotton42
jcotton422y ago
the signature of FillArray was provided for you? my guess is it's supposed to be the number of elements that were given by the user
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
BlasterBlaster
BlasterBlasterOP2y ago
Hello // Program demonstrates overloaded methods // that display an int, an amount of money, or a string // decorated with an argument character // or a default character 'X' using System; using static System.Console; using System.Globalization; class DebugEight4 { static void Main() { FancyDisplay(33); FancyDisplay(44, '@'); FancyDisplay(55.55); FancyDisplay(77.77, '*'); FancyDisplay("hello"); FancyDisplay("goodbye", '#'); } public static void FancyDisplay(int num, char decoration = 'X') { WriteLine("{0}{0}{0} {1} {0}{0}{0}\n", decoration, num); } public static void FancyDisply(double num, char decoration = 'X') { WriteLine("{0}{0}{0} {1} {0}{0}{0}\n", decoration, num.ToString("C", CultureInfo.GetCultureInfo("en-US"))); } public static void FancyDisplay(string word, char decoration = 'X') { WriteLine("{0}{0}{0} {1} {0}{0}{0}\n", decoration, word); } } Any clue why this isn't working? Error CS1503 Argument 1: cannot convert from 'double' to 'int' @line --- FancyDisplay(55.55);
jcotton42
jcotton422y ago
FancyDisply you made a typo here
BlasterBlaster
BlasterBlasterOP2y ago
@jcotton42 Gracias
Want results from more Discord servers?
Add your server