C#/Excel custom functions how to hide GetHashCode, ToString, GetType and Equals

Apr 6 2006 8:15 AM

Using the tutorial at this URL, I tried to create my own custom Excel functions which I could use in formulas.

http://blogs.msdn.com/eric_carter/archive/2004/12/01/273127.aspx

But I have no idea about how to hide these methods which probably inherits from default Object:

 - GetHashCode
 - ToString
 - GetType 
 - Equals

I would like to see only MultiplyNTimes when I insert the addin




using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;

 namespace CARDLibrary
{
[GuidAttribute("1F2A0E29-1934-4E2F-8E25-89467D68F3A9"), ProgId("The Addin!")
,ComVisible(
true),ClassInterface(ClassInterfaceType.AutoDual)]

public class Analytics
{
public Analytics(): base()
{
}

 

double MultiplyNTimes(double Number1, double Number2, double TimesToMultiply)

{

double result = Number1;

for (double i = 0; i < TimesToMultiply; i++)

{

result = result * Number2;

}

return result;

}

[ComRegisterFunctionAttribute]

public static void RegisterFunction(Type type)

{

Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type));

}

[ComUnregisterFunctionAttribute]
public static void UnregisterFunction(Type type)
{
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type),
false);
}

private static string GetSubKeyName(Type type)
{
string s = @"CLSID\{" + type.GUID.ToString().ToUpper() + @"}\Programmable";
return s;
}

}

}


Answers (2)