所以这是我绘制三角形的代码:
Graphics y = CreateGraphics();
Pen yy = new Pen(Color.Red);
pictureBox1.Refresh();
Point x = new Point(Convert.ToInt32(textBox1.Text)*10, Convert.ToInt32(textBox2.Text)*10);
Point xx = new Point(Convert.ToInt32(textBox3.Text)*10, Convert.ToInt32(textBox4.Text)*10);
Point xxx = new Point(Convert.ToInt32(textBox5.Text)*10, Convert.ToInt32(textBox6.Text)*10);
Point[] u = { x, xx, xxx };
y = pictureBox1.CreateGraphics();
y.DrawPolygon(yy, u);
Run Code Online (Sandbox Code Playgroud)
有没有办法围绕这个角落?我在谷歌上看到它,它似乎只有一种方法来圆角矩形,但不是三角形.
是否有任何命令要对我这样做,或者我必须手动执行此操作?
谢谢你的回复:)
我有这个整数数组: -
int[] numbers = new int[] { 10, 20, 30, 40 };
Run Code Online (Sandbox Code Playgroud)
我正在尝试创建一个数组,它将包含第一个元素,最后一个元素,第二个元素,倒数第二个元素等等.
所以,我的结果将是: -
int[] result = {10,40,20,30};
Run Code Online (Sandbox Code Playgroud)
这是我的方法,在一个循环从第一个开始直到中间和第二个循环从最后开始并到达中间并相应地选择项目,但我完全搞砸了.这是我尝试过的代码: -
private static IEnumerable<int> OrderedArray(int[] numbers)
{
bool takeFirst = true;
if (takeFirst)
{
takeFirst = false;
for (int i = 0; i < numbers.Length / 2; i++)
{
yield return numbers[i];
}
}
else
{
takeFirst = true;
for (int j = numbers.Length; j < numbers.Length / 2; j--)
{
yield return numbers[j];
}
}
}
Run Code Online (Sandbox Code Playgroud)
需要帮忙.
我有一个Dictionary<int, string>c#,我需要一种方法来创建一个字符串,其内容与格式"key1-value1, key2-value2"等.
我是c#的新手,所以我创建了以下功能来实现这个目标:
private string buildString(Dictionary<int, string> info)
{
string result = "";
int i = 1;
foreach (KeyValuePair<int, string> pair in info)
{
if (i < info.Count)
{
result += pair.Key + "-" + pair.Value + ",";
}
else
{
result += pair.Key + "-" + pair.Value;
}
i++;
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
但是,这个功能是有效和冗长的.我知道C#有String.format,但我不确定是否以及如何使用它.
有没有更好的方法以更有效和更简洁的方式实现相同的输出?如果是这样的话?
首先:我在不使用oop的情况下运行代码.我在同一个类中声明了所有变量,并在将查询传递给db之前和之后打开/关闭了连接.那很有效!现在有了一些新的经验,我试图将我的代码分成不同的类.现在它不再工作了.
它告诉我"连接必须有效且开放".足够的文字,这是我目前的代码:
Services.cs
public static MySqlConnection conn // Returns the connection itself
{
get
{
MySqlConnection conn = new MySqlConnection(Services.ServerConnection);
return conn;
}
}
public static string ServerConnection // Returns the connectin-string
{
get
{
return String.Format("Server={0};Port=XXXX;Database=xxx;Uid=xxx;password=xxXxxXxXxxXxxXX;", key);
}
}
public static void DB_Select(string s, params List<string>[] lists)
{
try
{
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
string command = s;
cmd.CommandText = command;
MySqlDataReader sqlreader = cmd.ExecuteReader();
while (sqlreader.Read())
{
if (sqlreader[0].ToString().Length > 0)
{
for (int i …Run Code Online (Sandbox Code Playgroud) Webapi响应状态码401时,如何禁用“需要身份验证”弹出窗口?

那是我的webapi配置
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(Startup.OAuthOptions.AuthenticationType));
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
//config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud) asp.net authentication asp.net-mvc asp.net-web-api asp.net-web-api2
为什么在MsSQL中,几毫秒会被舍入到下一个?例如:
SELECT CONVERT(datetime, '2006-04-25 15:50:59.996', 120)
Run Code Online (Sandbox Code Playgroud)
产生
2006-04-25 15:50:59.997
Run Code Online (Sandbox Code Playgroud) 我有2个函数执行相同的操作; 因为底层API有一个重载函数,它接受一个字符串或一个int.
由于我正在使用此函数,我需要使用字符串或int调用该函数.超载是唯一的方法吗?我复制代码,除了函数的签名; 而且似乎浪费了代码.
public void taketwo(int value1, int value2)
{
// Other operations happen here
baseAPI.getvalues(value1, value2);
}
public void taketwo(string val1_str, string val2_str)
{
// Other operations happen here
baseAPI.getvalues(val1_str, val2_str);
}
Run Code Online (Sandbox Code Playgroud)
我记得有关通用功能的事情; 但我不确定这是否适用于这种情况; 我以前从未使用它们,在潜入之前,我认为首先要问一下这个问题.
我有以下 XML 数据。我需要将其转换为 SQL 表。
<SalesDetails>
<Customer Name="Johny" DateofBirth="1990-01-02T00:00:00">
<OrderInfo>
<OrderDate>1993-02-03T00:00:00</OrderDate>
<OrderAmount>1000</OrderAmount>
</OrderInfo>
</Customer>
</SalesDetails>
Run Code Online (Sandbox Code Playgroud)
谁能帮助我执行一个 SQL 查询,将上述 XML 文件作为输出?
在最初的尝试中,我创建了两个表@TI 和@T2。然后我在其中插入了不同的值。然后我将其查询为:
SELECT
(SELECT * FROM @T1 FOR XML RAW('Sales') , TYPE),
(SELECT * FROM @T2 FOR XML PATH('OrderInfo') , TYPE)
FOR XML PATH('') , ROOT('SalesDetails')
Run Code Online (Sandbox Code Playgroud)
但我需要基于 SQL 表和相应联接的第一个 XML 格式的输出。即当显示客户姓名时,需要显示其对应的订单信息。我不希望它采用分组格式。
在Java中,您可以轻松地执行以下操作:
String[] result = input.split("AAA|BBB");
Run Code Online (Sandbox Code Playgroud)
这意味着如果您有这样的输入:
sssAAAvvvBBBuuu
Run Code Online (Sandbox Code Playgroud)
结果将是这样的:
sss
vvv
uuu
Run Code Online (Sandbox Code Playgroud)
在c#中执行此操作的最佳方法是什么,我知道在c#中很难用另一个字符串拆分字符串:
string[] result = input.Split(new string[] { "AAA" }, StringSplitOptions.None);
Run Code Online (Sandbox Code Playgroud)
但是如何用两个字符串AAA和BBB分割字符串呢?
c# ×7
.net ×2
sql-server ×2
arrays ×1
asp.net ×1
asp.net-mvc ×1
connection ×1
datetime ×1
dictionary ×1
monodevelop ×1
mysql ×1
rounding ×1
string ×1
xml ×1