C
C#16mo ago
Masmoudi

✅ im new to c# the problem is probably simple af

,
9 Replies
Masmoudi
MasmoudiOP16mo ago
how do i send the code?
Jimmacle
Jimmacle16mo ago
$code
MODiX
MODiX16mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Jimmacle
Jimmacle16mo ago
if it's an entire project (lots of files), github
Masmoudi
MasmoudiOP16mo ago
// using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Metoder_uppgoft_40
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
SumOfArray(numbers);
}
static void SumOfArray(Array numbers)
{
int total = numbers.Sum();

}
}
}
// using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Metoder_uppgoft_40
{
class Program
{
static void Main(string[] args)
{
int[] numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
SumOfArray(numbers);
}
static void SumOfArray(Array numbers)
{
int total = numbers.Sum();

}
}
}
so uh the numbers.sum in the SumOfArray isnt working it works if theyre both in the static void main
Jimmacle
Jimmacle16mo ago
the first thing is never use the Array type, use the actual type of the array which in this case is int[] you're losing information needed to access the Sum method
Masmoudi
MasmoudiOP16mo ago
oh that was as expected awefully simple lemme see if it works it did thanks alot man
Jimmacle
Jimmacle16mo ago
pepeok
Masmoudi
MasmoudiOP16mo ago
I appreciate the help

Did you find this page helpful?