Note that there are some explanatory texts on larger screens.

plurals
  1. POCompiling class in DLL and referencing it in another project in C#
    primarykey
    data
    text
    <p>Hope I'm asking this correctly.</p> <p>I have this class:</p> <pre><code>class ListUtilities { private List&lt;string&gt; _datalist; public ListUtilities(List&lt;string&gt; datalist) { _datalist = datalist; } //Method to calculate age from a date private int getAge(string bdaystr) { DateTime today = DateTime.Today; DateTime bday = new DateTime(Convert.ToInt32(bdaystr.Substring(0, 4)), Convert.ToInt32(bdaystr.Substring(4, 2)), Convert.ToInt32(bdaystr.Substring(6, 2))); int age = today.Year - bday.Year; if (bday &gt; today.AddYears(-age)) age--; return age; } //Method to print the data List public void printDataList() { for (int i = 0; i &lt; _datalist.Count; i++) { Console.WriteLine(_datalist.ElementAt(i)); } } //Method to calculate and print the ages public void printAges() { List&lt;int&gt; ages = new List&lt;int&gt;(); for (int i = 0; i &lt; _datalist.Count; i++) { string s = _datalist.ElementAt(i); string[] data = s.Split(','); ages.Add(getAge(data[3])); } Console.WriteLine("Ages:"); for (int i = 0; i &lt; ages.Count; i++) { Console.WriteLine(ages.ElementAt(i)); } } //Method to search by surname public string searchBySurname(string surname) { string res = ""; res = _datalist.Find(delegate(String str) { string[] data = str.Split(','); string sname = data[1]; if (sname == surname) return true; else return false; }); return res; } //Method to search by phone number public string searchByPhoneNumber(string phone) { string res = ""; res = _datalist.Find(delegate(String str) { string[] data = str.Split(','); string phn = data[4]; if (phn == phone) return true; else return false; }); return res; } //Method to search by age public string searchByAge(int age) { string res = ""; res = _datalist.Find(delegate(String str) { string[] data = str.Split(','); int age2 = Convert.ToInt32(getAge(data[3])); if (age2 == age) return true; else return false; }); return res; } //Method to sort by surname public int sortBySurname(string x, string y) { string[] data_x = x.Split(','); string sname_x = data_x[1]; string[] data_y = y.Split(','); string sname_y = data_y[1]; return String.Compare(sname_x, sname_y); } //Method to sort by phone number public int sortByPhoneNumber(string x, string y) { string[] data_x = x.Split(','); int phn_x = Convert.ToInt32(data_x[4]); string[] data_y = y.Split(','); int phn_y = Convert.ToInt32(data_y[4]); return phn_x.CompareTo(phn_y); } //Method to sort by age public int sortByAge(string x, string y) { string[] data_x = x.Split(','); int age_x = Convert.ToInt32(data_x[3]); string[] data_y = y.Split(','); int age_y = Convert.ToInt32(data_y[3]); return age_y.CompareTo(age_x); } } </code></pre> <p>and I want to compile it in a .DLL file. I have tried doing it by the console like this:</p> <pre><code>csc /target:library /out:MathLibrary.DLL Add.cs Mult.cs </code></pre> <p>and putting that class in a Class Library project and building it, and I get the DLL file in both cases but the problem comes when I want to use that DLL.</p> <p>I create a new Project, and I do reference the DLL file, but when I want to use it, this is the problem:</p> <p><img src="https://i.stack.imgur.com/BmfX4.png" alt="VS message"></p> <p>And, seems that there is nothing inside the DLL:</p> <p><img src="https://i.stack.imgur.com/dhtqE.png" alt="enter image description here"></p> <p>Best regards</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload