- Home /
CS0118 Error
//Sorry for posting so many errors, but I need these scripts for my game.
using UnityEngine;
using System.Collections;
namespace Stats {
public static class UpdateLists {
public static void UpdateInventory(Stats Stat)
{
for (int i = 0; i < Stat.Inventory.Length; i++)
{
if (Stat.Ability[i].name == "Potion")
{
Stat.Inventory[i].cost = 15;
Stat.Inventory[i].type = "Medicine";
Stat.Inventory[i].effect= "Heal";
Stat.Inventory[i].modifier = 30;
Stat.Inventory[i].description = "To restore health";
}
if (Stat.Ability[i].name == "Bomb")
{
Stat.Inventory[i].cost = 35;
Stat.Inventory[i].type = "Bomb";
Stat.Inventory[i].effect= "Explode";
Stat.Inventory[i].modifier = 50;
Stat.Inventory[i].description = "Damage enemies within an area of effect";
}
}
}
} }
// I am getting a CS0118 error at line 9 public static void UpdateInventory(Stats Stat)
'Stats is a namespace, but a 'type' was expected is what the error says.
Comment
Answer by $$anonymous$$ · Apr 17, 2012 at 09:54 AM
It is just as it says. Stats is a namespace, that is a kind of "directory of classes".
In your code, you use Stats as a class. To do so, you need to create a class called Stats.
You should also learn a bit more about the basics of C#.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070410im_/https://answers.unity.com/themes/thub/images/avi.jpg)