Click here to Skip to main content
16,016,744 members
Home / Discussions / C#
   

C#

 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 10:23
leppie29-Oct-02 10:23 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger29-Oct-02 10:54
perlmunger29-Oct-02 10:54 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 11:05
leppie29-Oct-02 11:05 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger29-Oct-02 11:11
perlmunger29-Oct-02 11:11 
GeneralRe: Determing SQL Server Type from C# Pin
leppie29-Oct-02 11:39
leppie29-Oct-02 11:39 
GeneralRe: Determing SQL Server Type from C# Pin
Stephane Rodriguez.29-Oct-02 18:36
Stephane Rodriguez.29-Oct-02 18:36 
GeneralRe: Determing SQL Server Type from C# Pin
perlmunger30-Oct-02 9:07
perlmunger30-Oct-02 9:07 
GeneralPass By Reference Problem Pin
perlmunger29-Oct-02 6:34
perlmunger29-Oct-02 6:34 
GeneralRe: Pass By Reference Problem Pin
Daniel Turini29-Oct-02 6:40
Daniel Turini29-Oct-02 6:40 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 6:51
perlmunger29-Oct-02 6:51 
GeneralRe: Pass By Reference Problem Pin
leppie29-Oct-02 7:42
leppie29-Oct-02 7:42 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 9:18
perlmunger29-Oct-02 9:18 
GeneralRe: Pass By Reference Problem Pin
LongRange.Shooter29-Oct-02 8:42
LongRange.Shooter29-Oct-02 8:42 
GeneralRe: Pass By Reference Problem Pin
perlmunger29-Oct-02 9:20
perlmunger29-Oct-02 9:20 
GeneralRe: Pass By Reference Problem Pin
Paul Ingles29-Oct-02 14:40
Paul Ingles29-Oct-02 14:40 
GeneralFloat divisoin Pin
Mazdak29-Oct-02 1:08
Mazdak29-Oct-02 1:08 
GeneralRe: Float divisoin Pin
Pete Bassett29-Oct-02 1:20
Pete Bassett29-Oct-02 1:20 
GeneralRe: Float divisoin Pin
Nick Parker29-Oct-02 1:21
protectorNick Parker29-Oct-02 1:21 
GeneralRe: Float divisoin Pin
Mazdak29-Oct-02 4:03
Mazdak29-Oct-02 4:03 
GeneralDrag and Drop Pin
Buddhi28-Oct-02 23:36
Buddhi28-Oct-02 23:36 
QuestionHow to count event subscriptions Pin
BigAndy28-Oct-02 23:11
BigAndy28-Oct-02 23:11 
AnswerRe: How to count event subscriptions Pin
Stephane Rodriguez.29-Oct-02 0:04
Stephane Rodriguez.29-Oct-02 0:04 
GeneralRe: How to count event subscriptions Pin
BigAndy29-Oct-02 1:28
BigAndy29-Oct-02 1:28 
GeneralRe: How to count event subscriptions Pin
Stephane Rodriguez.29-Oct-02 1:56
Stephane Rodriguez.29-Oct-02 1:56 
More info on delegate type is needed to provide full source code.

I guess this code will be helpful :
class App {

   // Definition of delegate that allows quering a component's status
   delegate String GetStatus();

   static void Main() {
      // Declare an empty delegate chain
      GetStatus getStatus = null;

      // Construct the 3 components and add their status methods 
      // to the delegate chain
      getStatus += new GetStatus(new Light().SwitchPosition);
      getStatus += new GetStatus(new Fan().Speed);
      getStatus += new GetStatus(new Speaker().Volume);

      // Show consolidated status report reflecting 
      // the condition of the 3 components
      Console.WriteLine(GetComponentStatusReport(getStatus));
   }

   // Method that queries several components and returns a status report
   static String GetComponentStatusReport(GetStatus status) {

      // If the chain is empty, there is nothing to do
      if (status == null) return null;

      // Use this to build the status report
      StringBuilder report = new StringBuilder();

      // Get an array where each element is a delegate from the chain
      Delegate[] arrayOfDelegates = status.GetInvocationList();

      // Iterate over each delegate in the array 
      foreach (GetStatus getStatus in arrayOfDelegates) {

         try {
            // Get a component's status string and append it to the report
            report.Append(getStatus() + "\r\n\r\n");
         }
         catch (Exception e) {
            // Generate an error entry in the report for this component
            Object component = getStatus.Target;
            report.Append("Failed to get status from " +
               ((component == null) ? "" : component.GetType() + ".") + 
               getStatus.Method.Name + 
               "\r\n   Error: " + e.Message + "\r\n\r\n");
         }
      }

      // Return the consolidated report to the caller
      return report.ToString();
   }
}




How low can you go ?
(MS rant)

GeneralC# .NET and Microsoft Excel Pin
mee28-Oct-02 16:22
mee28-Oct-02 16:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.