小编Wil*_*mpt的帖子

基于任意格式将字符串转换为TDateTime

在Delphi 5中是否有任何方法可以将字符串转换为TDateTime,您可以在其中指定要使用的实际格式?

I'm working on a jobprocessor, which accepts tasks from various workstations. The tasks have a range of parameters, some of which are dates, but (unfortunately, and out of my control) they're passed as strings. Since the jobs can come from different workstations, the actual datetime format used to format the dates as a string might (and, of course, actual do) differ.

Googling around, the only quick solutions I found was to sneakily change the ShortDateFormat variable, and …

delphi delphi-5

21
推荐指数
4
解决办法
4万
查看次数

枚举和减法运算符

有没有人知道(也许:从什么时候开始)-=运营商支持enum价值观?

今天我很乐意编写代码,因为我出于某种原因写了这个以从标志中排除一个值enum:

flags -= FlagsEnum.Value1;
Run Code Online (Sandbox Code Playgroud)

在重新阅读和评估我的代码之后,我很惊讶它编译实际上有效.

将陈述写为

flags = flags - FlagsEnum.Value1
Run Code Online (Sandbox Code Playgroud)

但也不能编译.

到目前为止,我在文档和互联网上找不到任何内容.此外,不支持其他运算符(当然除了位运算符):( +=包括标志),*=(Pascal中的交集)不起作用.

这是一些内置于C#编译器的语法糖吗?如果是这样,他们选择不包括其他运营商的任何理由?

一个简单的代码示例:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    [Flags]
    enum FlagsEnum
    {
        None = 0,
        Value1 = 1,
        Value2 = 2,
        Value3 = 4
    }

    class Program
    {
        static void Main(string[] args)
        {
            FlagsEnum flags = FlagsEnum.Value1 | FlagsEnum.Value2 | FlagsEnum.Value3;
            Console.WriteLine(flags);
            flags -= FlagsEnum.Value1;
            Console.WriteLine(flags);
            flags -= FlagsEnum.Value3; …
Run Code Online (Sandbox Code Playgroud)

c# enums

16
推荐指数
2
解决办法
4580
查看次数

标签 统计

c# ×1

delphi ×1

delphi-5 ×1

enums ×1