Abdullahi Farah Abdullahi Farah - 3 months ago 6
C# Question

what is list<> and fetch combo in c#

While viewing some code on an application I'm working on I see code that looks like this

using System.Collections.Generic;

namespace Test.Entity
{
public interface Itest: Iinfo
{
List<Entity> Fetch(int ID,
string Name,
string StateId);
}
}


I know what List<> is and where it comes from (
System.Collections.Generic
), but can't seem to find anything online about the Fetch that comes after it. Also can't find anything in the
Iinfo
Interface about Fetch. Where does the
Fetch(*stuff*)
come from?

Answer

To answer your questions:

  • Iinfo is an interface defined in your application. Click on the word Iinfo and hit F12 to see the definition.

  • Fetch is a method defined in your interface Itest. If a non-abstract class wants to implement your Itest interface, it must implement a method Fetch with the given parameters, returning a List<Entity>.

Notes:

  • The .NET naming conventions say that your interfaces should be called IInfo and ITest (PascalCase after the initial I), and that your parameters should be called id, name and stateId (camelCase).

  • If you are working on this application, use this opportunity to update its documentation. Find whoever wrote Itest and Iinfo, interview them to find out what these interfaces do, and then write down your findings in XML comments, so that the next poor guy maintaining this app won't be in the same situation as you are now.

Comments