question

WilliamOGorm-1523 avatar image
0 Votes"
WilliamOGorm-1523 asked cooldadtx commented

Error CSOO5 when I try to export class of strings

Hello. I'm trying to create and export a class of 3 strings to use in other pats of the app, and I'm getting a CSO050 error. Much thanks in advance!
Windows Forms App (.NET Framework) C#

namespace DM
{
public class RandomNameGenerator
{
class CharacterExportTemplate
{
public string title;
public string firstname;
public string lastname;

         public string Title
         {
             get { return title; }
             set { title = value; }
         }

         public string Firstname
         {
             get { return firstname; }
             set { firstname = value; }
         }
         public string Lastname
         {
             get { return lastname; }
             set { lastname = value; }
         }
     }
     CharacterExportTemplate characterexport = new CharacterExportTemplate();
     public CharacterExportTemplate NameGenerator()                                                          >> Error here, on NameGenerator
     {

         Random rnd = new Random();
         string Titletemp = "";
         string Firstnametemp = "";
         string Lastnametemp = "";
         characterexport.title = "";
         characterexport.firstname = "";
         characterexport.lastname = "";
         int mf = rnd.Next(2) + 1;                              // Decide if character  is male or female.
         int no = rnd.Next(10) + 1;                             // Decide if character  is nobility.
         int nfn = rnd.Next(3) + 1;                             // Number of first names.
         if (no != 10) { nfn = 1; }
         if (mf > 1)                                            // Female

         {
             if (no == 10)
             {
                 int tt = rnd.Next(16);
                 for (int ii = 0; ii < tt; ii++)
                 {
                     Titletemp = "";
                     Titletemp = Titletemp + Lore.TitlesFemale[ii];
                 }
                 characterexport.title = characterexport.title + Titletemp + " ";
             }
             else { Titletemp = ""; }
             for (int i = 0; i < nfn; i++)
             {
                 int fn = rnd.Next(34);
                 for (int iii = 0; iii < fn; iii++)
                 {
                     Firstnametemp = "";
                     Firstnametemp = Firstnametemp + Lore.FirstNamesFemale[iii];
                 }
                 characterexport.firstname = characterexport.firstname + Firstnametemp + " ";
             }
         }
         else                                                   // Male 
         {
             if (no == 10)
             {
                 int tt = rnd.Next(21);
                 for (int ii = 0; ii < tt; ii++)
                 {
                     Titletemp = "";
                     Titletemp = Titletemp + Lore.TitlesMale[ii];
                 }
                 characterexport.title = characterexport.title + Titletemp + " ";
             }
             else { Titletemp = ""; }
             for (int i = 0; i < nfn; i++)
             {
                 int fn = rnd.Next(34);
                 for (int iii = 0; iii < fn; iii++)
                 {
                     Firstnametemp = "";
                     Firstnametemp = Firstnametemp + Lore.FirstNamesMale[iii];
                 }
                 characterexport.firstname = characterexport.firstname + Firstnametemp + " ";
             }

         }
         int ln = rnd.Next(52);
         for (int ii = 0; ii < ln; ii++)
         {
             Lastnametemp = "";
             Lastnametemp = Lastnametemp + Lore.LastNames[ii];
         }
         characterexport.lastname = characterexport.lastname + Lastnametemp;
         return characterexport;
     }
 }

}

windows-forms
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The code you posted isn't the full code so we are only guessing at the problem. It looks like the start of a valid method but that would completely depend upon what the code looks like before that line including the class definition. Given just the block of code it appears that just before it is a class containing some properties. Unless that class is a nested type inside the class that owns the method you're having issues with it won't compile.

Please post the class containing the method and please provide the error message. As far as I know there is no CS005 error in C# list.

0 Votes 0 ·

That did it, Viorel. Thanks!

0 Votes 0 ·

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try adding public:

public class CharacterExportTemplate ...



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.