c# - 我应该在控制台应用程序中使用 System.Drawing 吗?
问题描述
我正在用 C# 制作控制台游戏,很多时候我必须管理对象的位置或大小。所以我想我Point
会Size
使用System.Drawing
. 但是,当我用谷歌搜索该命名空间时,有很多结果都在谈论 Windows 窗体,但是这些结构是否也用于控制台应用程序?还是人们只是为此制作自己的小结构?只是一个简单的问题,我想知道最佳实践是什么。
例子:
using System.Drawing;
class Entity
{
public Point Position;
public Size Size;
// Other entity stuff
}
或者:
class Entity
{
public int X, Y, Width, Height;
// Other entity stuff
}
或者:
class Entity
{
public Point Position;
public Size Size;
// Other entity stuff
}
struct Point
{
public int X, Y;
public Point(int x, int y)
{
X = x;
Y = y;
}
}
struct Size
{
public int Width, Height;
public Point(int width, int height)
{
Width = width;
Height = height;
}
}
此外,该System.Drawing.Point
结构附有很多东西,所以我不知道。
解决方案
推荐阅读
- python - 梯度下降实施python - 等高线
- jenkins - 詹金斯跳过自由式工作链中的一些工作
- docker - Kafka Streams 消费者组并发:仅从一个分区消费?
- wordpress - Woocommerce - 产品单页中的作者简介
- javascript - 使用带有 office-js-helpers 身份验证器的 msgraph-sdk-javascript 的令牌错误
- swagger - Swagger 如何显示模型中的所有字段但仅显示示例值中的某些字段(SpringBoot 项目)
- swift - 使用协议集获取具有 nil 值的 var
- python - 如何在python中遍历字典中的键和值
- google-cloud-platform - 我可以为 Pub/Sub 消息指定 ttl 吗?
- css - 移动应用到桌面的媒体查询