创建和使用用户定义类型时出现问题 [英] problem creating and using user defined type

查看:122
本文介绍了创建和使用用户定义类型时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读C#一段时间了
但我在将我的课程用作
时遇到问题 用户定义类型.

例如.字符串名称;//名称可以接受TextBox中的值

我有一堂课

公共课瓶
{
公共Bottle()
{

}

}

我如何使用我的班级类型??

有人可以帮帮我吗?

I have been reading C# for some time now
but i am having problem with using my class as
a user define type.

eg. string name;//names can accept values from TextBox

and i have a class

Public class Bottle
{
public Bottle()
{

}

}

how do i use my class a type???

Can someone help me out???

推荐答案

在我看来,您需要精读一本有关C#基础知识的书(或一般而言的OO编程... ).

无论如何,这是您的答案:
It seems to me that you need to reed a book about the basics of C# (or OO programming in general...).

Anyway, here is your answer:
// Create a new variable of your custom type

Bottle myBottle;


// Create a new Bottle object and assign it to our variable

myBottle = new Bottle();


这篇关于创建和使用用户定义类型时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆