将 C# 转换为 VB.NET 时出错
Error whilst translating C# to VB.NET
有人可以翻译 VB.NET 中的以下内容吗?
// propare a few short names
ChartArea CA = chart1.ChartAreas[0];
Series S1 = chart1.Series[0];
// this would be option one:
S1.IsValueShownAsLabel = true;
// we clear any previous CustomLabels
CA.AxisY.CustomLabels.Clear();
// we create a version of our points collection which sorted by Y-Values:
List<DataPoint> ptS = S1.Points.OrderBy(x => x.YValues[0]).ToList();
// now, for option three we add the custom labels:
for (int p = 0; p < ptS.Count; p++)
{
CustomLabel L = new CustomLabel(ptS[p].YValues[0] - 0.5,
ptS[p].YValues[0] + 0.5,
ptS[p].YValues[0].ToString("##0.0000"),
0, LabelMarkStyle.None);
CA.AxisY.CustomLabels.Add(L);
// this is option two: tooltips for each point
ptS[p].ToolTip = ptS[p].YValues[0].ToString("##0.0000");
}
这来自以下 Stack Overflow 问题:
在不舍入的情况下在 Y 轴上显示 Y 值[关闭]
我尝试了以下方法:
area1.AxisY.CustomLabels.Clear()
Dim pointSeries As List(Of DataPoint)
**Line with error:**
pointSeries = mySeriesRecord.Points.OrderBy(Function(x) x.YValues(0))
Dim len As Integer = pointSeries.Count()
For p As Integer = 0 To pointSeries.Count Step 1
Dim L As CustomLabel
L = New CustomLabel(pointSeries(p).YValues(0), pointSeries(p).YValues(len) + 0.5, pointSeries(p).YValues(0).ToString("##':'#0.00"), 0, LabelMarkStyle.None)
area1.AxisY.CustomLabels.Add(L)
Next
但这不起作用。错误是:
OrderedEnumerable
2[System.Web.UI.DataVisualization.Charting.DataPoint,System.Double]
unable to convert to type System.Collections.Generic.List
如有任何帮助,我们将不胜感激。
罗伯特
你试过这样的东西吗?
Dim ptS As List(Of DataPoint) = S1.Points.OrderBy(Function(x) x.YValues(0)).ToList()
要转换 from/to C# to/from VB.NET 你可以使用 telerik 的在线工具:
http://converter.telerik.com/
有人可以翻译 VB.NET 中的以下内容吗?
// propare a few short names
ChartArea CA = chart1.ChartAreas[0];
Series S1 = chart1.Series[0];
// this would be option one:
S1.IsValueShownAsLabel = true;
// we clear any previous CustomLabels
CA.AxisY.CustomLabels.Clear();
// we create a version of our points collection which sorted by Y-Values:
List<DataPoint> ptS = S1.Points.OrderBy(x => x.YValues[0]).ToList();
// now, for option three we add the custom labels:
for (int p = 0; p < ptS.Count; p++)
{
CustomLabel L = new CustomLabel(ptS[p].YValues[0] - 0.5,
ptS[p].YValues[0] + 0.5,
ptS[p].YValues[0].ToString("##0.0000"),
0, LabelMarkStyle.None);
CA.AxisY.CustomLabels.Add(L);
// this is option two: tooltips for each point
ptS[p].ToolTip = ptS[p].YValues[0].ToString("##0.0000");
}
这来自以下 Stack Overflow 问题: 在不舍入的情况下在 Y 轴上显示 Y 值[关闭]
我尝试了以下方法:
area1.AxisY.CustomLabels.Clear()
Dim pointSeries As List(Of DataPoint)
**Line with error:**
pointSeries = mySeriesRecord.Points.OrderBy(Function(x) x.YValues(0))
Dim len As Integer = pointSeries.Count()
For p As Integer = 0 To pointSeries.Count Step 1
Dim L As CustomLabel
L = New CustomLabel(pointSeries(p).YValues(0), pointSeries(p).YValues(len) + 0.5, pointSeries(p).YValues(0).ToString("##':'#0.00"), 0, LabelMarkStyle.None)
area1.AxisY.CustomLabels.Add(L)
Next
但这不起作用。错误是:
OrderedEnumerable 2[System.Web.UI.DataVisualization.Charting.DataPoint,System.Double] unable to convert to type System.Collections.Generic.List
如有任何帮助,我们将不胜感激。
罗伯特
你试过这样的东西吗?
Dim ptS As List(Of DataPoint) = S1.Points.OrderBy(Function(x) x.YValues(0)).ToList()
要转换 from/to C# to/from VB.NET 你可以使用 telerik 的在线工具: http://converter.telerik.com/