当前位置: 首页>>代码示例>>C#>>正文


C# Unit.ToString方法代码示例

本文整理汇总了C#中Unit.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.ToString方法的具体用法?C# Unit.ToString怎么用?C# Unit.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unit的用法示例。


在下文中一共展示了Unit.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitTestUnits

    public static List<Unit> InitTestUnits()
    {
        var unit1Spec = "S,B,B,P,P,P,SS";
        var unit2Spec = "S,S,B,B,P,P,SS";
        var defaultUnit = new Unit();
        var unit1 = defaultUnit.Clone("Ansible-I");
        unit1.setComponentSpec(unit1Spec);
        var unit2 = unit1.Clone();

        Console.WriteLine("INFO: {0}", defaultUnit.ToString());
        Debug.Print("INFO: {0}", defaultUnit.ToString());

        Console.WriteLine("INFO: {0}", unit1.ToString());
        Debug.Print("INFO: {0}", unit1.ToString());

        Console.WriteLine("INFO: {0}", unit2.ToString());
        Debug.Print("INFO: {0}", unit2.ToString());

        Debug.Print("Re-Spec Unit 2...");
        unit2.Name = "Ansible-II";
        unit2.setComponentSpec(unit2Spec);
        Console.WriteLine("INFO: {0}", unit2.ToString());
        Debug.Print("INFO: {0}", unit2.ToString());

        return new List<Unit>() { unit1, unit2 };
    }
开发者ID:skeolan,项目名称:WarpWar,代码行数:26,代码来源:Program.cs

示例2: ToString

 public static string ToString(Unit u)
 {
     if (u == Unit.Percent) {
         return "%";
     } else if (u == Unit.Hz || u == Unit.kHz) {
         return u.ToString();
     } else if (u == Unit.None) {
         return "";
     }
     return u.ToString().ToLower();
 }
开发者ID:xescrp,项目名称:breinstormin,代码行数:11,代码来源:Unit.cs

示例3: ToString

 public static string ToString(Unit u)
 {
     if (u == Unit.Percent)
     {
         return "%";
     }
     else if (u == Unit.Hz || u == Unit.kHz)
     {
         return u.ToString();
     }
     else if (u == Unit.None)
     {
         return "";
     }
     return u.ToString().ToLower(CultureInfo.InvariantCulture);
 }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:16,代码来源:Unit.cs

示例4: Unit

 public void Unit()
 {
     var u1 = new Unit();
     var u2 = new Unit();
     Assert.True(u1.Equals(u2));
     Assert.False(u1.Equals(""));
     Assert.False(u1.Equals(null));
     Assert.True(u1 == u2);
     Assert.False(u1 != u2);
     Assert.Equal(0, u1.GetHashCode());
     Assert.Equal("()", u1.ToString());
 }
开发者ID:RolandPheasant,项目名称:Rx.NET,代码行数:12,代码来源:UnitTest.cs

示例5: Pack

 private void Pack(string type, string name, Unit unit, MetricTags tags, IEnumerable<JsonProperty> properties)
 {
     this.data.Add(new ESDocument
     {
         Index = this.elasticSearchIndex,
         Type = type,
         Object = new JsonObject(new[] { 
                  new JsonProperty("Timestamp", Clock.FormatTimestamp(this.CurrentContextTimestamp)),
                  new JsonProperty("Type",type),
                  new JsonProperty("Name",name),
                  new JsonProperty("Unit", unit.ToString()),
                  new JsonProperty("Tags", tags.Tags)
              }.Concat(properties))
     });
 }
开发者ID:kucheruk,项目名称:Metrics.NET,代码行数:15,代码来源:ElasticSearchReport.cs

示例6: GetRenderStyleValue

    protected string GetRenderStyleValue(string name, Unit value)
    {
        if (!value.IsEmpty)
        {
            return name + ":" + value.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLowerInvariant() + ";";
        }
 
        // Do not render the value
        return "";
    }
开发者ID:Gordon-from-Blumberg,项目名称:Piczard.Examples,代码行数:10,代码来源:SimpleImageUpload.ascx.cs

示例7: PrefixedToString

 public void PrefixedToString()
 {
     var u1 = new Unit(1, Prefix.k, BaseUnit.mol);
     Assert.Equal("1kmol", u1.ToString());
 }
开发者ID:milutinovici,项目名称:metric,代码行数:5,代码来源:UnitTest.cs

示例8: Init

        public void Init()
        {
            this.Icon = Properties.Resources.Map;
            this.DialogResult = DialogResult.Cancel;

            _killThread = false;

            #if (PocketPC || WindowsCE || Mobile)
            if (Values.Settings.DeviceOptions.UseSelection)
            {
                btnDist.Visible = true;
                btnLoc.Visible = true;
                btnPoly.Visible = true;
                btnStart.Visible = true;
                btnSample.Visible = true;

                cboDist.Visible = false;
                cboLoc.Visible = false;
                cboPoly.Visible = false;
                cboSample.Visible = false;
                cboStart.Visible = false;
            }
            else
            {
                btnDist.Visible = false;
                btnLoc.Visible = false;
                btnPoly.Visible = false;
                btnStart.Visible = false;
                btnSample.Visible = false;

                cboDist.Visible = true;
                cboLoc.Visible = true;
                cboPoly.Visible = true;
                cboSample.Visible = true;
                cboStart.Visible = true;
            }
            #endif

            ix = 100;
            iy = 100;
            delOld = true;
            tilt = null;

            lstPoly = new List<string>();
            lstDist = new List<string>();
            lstLoc = new List<string>();

            _Polys = DAL.GetPolygons();

            if (_Polys.Count < 1)
            {
                MessageBox.Show("");
                this.DialogResult = DialogResult.Abort;
            }
            else
            {
                foreach (TtPolygon poly in _Polys)
                {
                    cboPoly.Items.Add(poly.Name);
                    lstPoly.Add(poly.Name);
                }

                ChangePoly(_Polys[0].CN);

                lstLoc.Add(PointLocation.Inside.ToString());
                lstLoc.Add(PointLocation.Extents.ToString());

                cboLoc.Items.Add(PointLocation.Inside);
                cboLoc.Items.Add(PointLocation.Extents);

                lstDist.Add(Unit.FEET_TENTH.ToString());
                lstDist.Add(Unit.METERS.ToString());
                //lstDist.Add(Unit.FEET_INCHES.ToString());
                //lstDist.Add(Unit.YARDS.ToString());
                lstDist.Add(Unit.CHAINS.ToString());

                cboDist.Items.Add(Unit.FEET_TENTH);
                cboDist.Items.Add(Unit.METERS);
                //cboDist.Items.Add(Unit.FEET_INCHES);
                //cboDist.Items.Add(Unit.YARDS);
                cboDist.Items.Add(Unit.CHAINS);

                cboLoc.SelectedIndex = 0;
                cboDist.SelectedIndex = 0;
                cboPoly.SelectedIndex = 0;

                dist = Unit.FEET_TENTH;
                PolyCN = _Polys[0].CN;
                loc = PointLocation.Inside;

            #if (PocketPC || WindowsCE || Mobile)
                btnPoly.Text = lstPoly[0];
                btnLoc.Text = loc.ToString();
                btnDist.Text = dist.ToString();
            #endif
                sType = SampleType.Percent;

                cboSample.Items.Add(SampleType.Percent.ToString());
                cboSample.Items.Add(SampleType.Points.ToString());

//.........这里部分代码省略.........
开发者ID:FMSC-Measurements,项目名称:TwoTrailsV2,代码行数:101,代码来源:PlotGridForm.Logic.cs

示例9: ConvertFunc

        private Func<CommandEventArgs, Task> ConvertFunc() =>
            async e =>
            {
                try
                {
                    await e.Channel.SendIsTyping();

                    string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
                    string to = e.GetArg("from-to").ToLowerInvariant().Split('>')[1];

                    float quantity = 1.0f;
                    if (!float.TryParse(e.GetArg("quantity"), out quantity))
                    {
                        quantity = 1.0f;
                    }

                    int fromCode, toCode = 0;
                    UnitTable table = null;
                    ResolveUnitCodes(from, to, out table, out fromCode, out toCode);

                    if (table != null)
                    {
                        Unit inUnit = new Unit(fromCode, quantity, table);
                        Unit outUnit = inUnit.Convert(toCode);
                        await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString());
                    }
                    else
                    {
                        reInitCurrencyConverterTable();
                        Unit inUnit = currTable.CreateUnit(quantity, from.ToUpperInvariant());
                        Unit outUnit = inUnit.Convert(currTable.CurrencyCode(to.ToUpperInvariant()));
                        await e.Channel.SendMessage(inUnit.ToString() + " = " + outUnit.ToString());
                    }
                }
                catch //(Exception ex)
                {
                    //Console.WriteLine(ex.ToString());
                    await e.Channel.SendMessage("Bad input format, or sth went wrong... Try to list them with `" + Module.Prefix + "`convertlist");
                }
            };
开发者ID:magicvoid1,项目名称:NadekoBot,代码行数:40,代码来源:ConverterCommand.cs

示例10: RecognizeDerivedUnit

 public void RecognizeDerivedUnit()
 {
     var mn = new Unit(12, BaseUnit.m) * new Unit(1, Prefix.k, BaseUnit.g) * new Unit(1, BaseUnit.s, -2);
     Assert.Equal("12N", mn.ToString());
 }
开发者ID:milutinovici,项目名称:metric,代码行数:5,代码来源:ComplexUnitTest.cs

示例11: GetUnitPrefab

 /// <summary>
 /// TODO string をcache
 /// </summary>
 public Object GetUnitPrefab(Unit.Type unitType)
 {
     return Resources.Load(Define.Path.Models.BASE + unitType.ToString());
 }
开发者ID:RyoIwanaga,项目名称:HeroesStrategySource,代码行数:7,代码来源:ResourceManager.cs

示例12: RecognizeDerivedUnitWithPrefix2

 public void RecognizeDerivedUnitWithPrefix2()
 {
     var u = new Unit(2, new Unit(Prefix.h, BaseUnit.g), new Unit(Prefix.M, BaseUnit.m), new Unit(BaseUnit.s, -2));
     Assert.AreEqual("200kN", u.ToString());
 }
开发者ID:cukaric,项目名称:MeasurementUnits,代码行数:5,代码来源:ComplexUnitTest.cs

示例13: RecognizeDerivedUnitWithPrefix

 public void RecognizeDerivedUnitWithPrefix()
 {
     var kn = new Unit(1, new Unit(Prefix.k, BaseUnit.g), new Unit(Prefix.k, BaseUnit.m), new Unit(BaseUnit.s, -2));
     Assert.AreEqual("1kN", kn.ToString());
 }
开发者ID:cukaric,项目名称:MeasurementUnits,代码行数:5,代码来源:ComplexUnitTest.cs

示例14: btnDist_Click2

 private void btnDist_Click2(object sender, EventArgs e)
 {
     using (Selection form = new Selection("Measurement Type", lstDist, lstDist.IndexOf(dist.ToString())))
     {
         if (form.ShowDialog() == DialogResult.OK)
         {
             dist = (Unit)Enum.Parse(typeof(Unit), lstDist[form.selection], true);
             btnDist.Text = dist.ToString();
             cboDist.SelectedIndex = form.selection;
         }
     }
 }
开发者ID:FMSC-Measurements,项目名称:TwoTrailsV2,代码行数:12,代码来源:PlotGridForm.Logic.cs

示例15: WithDivisor

 public string WithDivisor()
 {
     var u = new Unit(1, Prefix.m, BaseUnit.m) * new Unit(1, BaseUnit.s, -2);
     return u.ToString("dc");
 }
开发者ID:milutinovici,项目名称:metric,代码行数:5,代码来源:ComplexUnitPerformanceTest.cs


注:本文中的Unit.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。