C
C#11mo ago
Rayzenn_

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

,
9 Replies
Rayzenn_
Rayzenn_OP11mo ago
how do i send the code?
Jimmacle
Jimmacle11mo ago
$code
MODiX
MODiX11mo 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
Jimmacle11mo ago
if it's an entire project (lots of files), github
Rayzenn_
Rayzenn_OP11mo 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
Jimmacle11mo 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
Rayzenn_
Rayzenn_OP11mo ago
oh that was as expected awefully simple lemme see if it works it did thanks alot man
Jimmacle
Jimmacle11mo ago
pepeok
Rayzenn_
Rayzenn_OP11mo ago
I appreciate the help
Want results from more Discord servers?
Add your server