C# 从其他类使用IntPtr

C# 从其他类使用IntPtr,c#,C#,我正在为文本框使用自定义光标 这个方法对我来说很好 [DllImport("user32.dll")] static extern IntPtr LoadCursorFromFile(string lpFileName); 但是我需要使用其他类中的这个方法 我已经创建了ClassImage\u图标 class Image_Icon { [DllImport("user32.dll")] static extern IntPtr LoadCursorFro

我正在为文本框使用自定义光标

这个方法对我来说很好

[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);
但是我需要使用其他类中的这个方法 我已经创建了Class
Image\u图标

class Image_Icon
{
[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);

public IntPtr Search_cursor_C()
{
IntPtr Search_cursor = LoadCursorFromFile(Application.StartupPath + "\\SearchCursor.cur");
return (Search_cursor);
}
我正在使用此代码获取游标

txt_Vacation_Calculate_Type_Code.Cursor = new Cursor(Image_Icon.Search_cursor_C);
但看起来好像有什么不对劲 我得到这个错误

严重性代码说明项目文件行抑制状态 错误CS1503参数1:无法从“方法组”转换为“IntPtr”工资单C:\Users\Ahmed Abdo\Desktop\WorkNow\PayRoll\PayRoll\PayRoll\Basis\frmEmployeeData.cs 68 Active


如何从其他类访问该类,并使用搜索游标使函数保持静态,并返回游标:

class Image_Icon
{

    [DllImport("user32.dll")]
    static extern IntPtr LoadCursorFromFile(string lpFileName);

    public static Cursor Search_cursor_C()
    {
        return new Cursor(LoadCursorFromFile(System.IO.Path.Combine(Application.StartupPath, "SearchCursor.cur")));
    }

}
然后像这样使用它:

txt_Vacation_Calculate_Type_Code.Cursor = Image_Icon.Search_cursor_C();

您需要调用
Search\u cursor\u C
method。。。它也应该是静态的,或者您应该从类实例调用它。。。也请参加一些C#课程。。。如果您遇到编译时错误,主要是因为您不懂语言(或拼写错误),这是否回答了您的问题?@塞尔文。。。OK此方法在windows 7中不起作用请查看此处
txt_Vacation_Calculate_Type_Code.Cursor = Image_Icon.Search_cursor_C();