OK, so a class in my project goes through this method.
public static MemberName SplitTdsName(string tdsName)
{
NameSplitter preSplitName = new NameSplitter(tdsName);
return preSplitName;
}
MemberName is a struct:
public struct MemberName
{
public string Title;
public string FirstNames;
public string LastNames;
public MemberName(string title, string firstNames, string lastNames)
{
Title = title;
FirstNames = firstNames;
LastNames = lastNames;
}
}
And NameSplitter class:
public NameSplitter(string fullName)
{
nameInFull = fullName;
SetAllowedTitles();
SplitNamesAndRemovePeriods();
SetTitles();
MemberName splitName = new MemberName(titles, firstNames, lastNames);
return splitName;
}
This won’t work because when I change public NameSplitter to public MemberName NameSplitter the SplitTdsName method tells me NameSplitter doesn’t have a method that takes one argument.
I don’t know how to work around this or get it to work. Do I need to change NameSplitter to a NameSplitter a static class?
Note: I KNOW THE CODE IS WRONG
Went with:
public static MemberName SplitTdsName(string tdsName)
{
return NameSplitter.NameSplitter(tdsName);
}
public static MemberName NameSplitter(string fullName)
{
nameInFull = fullName;
SetAllowedTitles();
SplitNamesAndRemovePeriods();
SetTitles();
MemberName splitName = new MemberName(titles, firstNames, lastNames);
return splitName;
}
public MemberName(string title, string firstNames, string lastNames)
{
Title = title;
FirstNames = firstNames;
LastNames = lastNames;
}
Try to implement the class like:
and then use as
MemberName mn = NameSplitter.Split("<your data here>");Final code can look like: