小编use*_*108的帖子

数字文字后面的C#后缀

我是C#的新手,想要了解价值观是如何运作的.如果我查看一个正常的整数值,它有三个重要部分:类型,名称和值.

int testInt = 3;
 |    |       |
Type Name   Value
Run Code Online (Sandbox Code Playgroud)

但是当我看到浮点值时,由于后缀,它会让我感到困惑F.

float testFloat = 3.0F;
  |      |        |  |
 Type   Name  Value Type
Run Code Online (Sandbox Code Playgroud)

现在有两种类型,如果没有F后缀,则值为double.但是,当我可以用声明双变量时,为什么会发生这种情况

double testDouble = 3.0D;
Run Code Online (Sandbox Code Playgroud)

double作为第一个词应该是足够了,不应该吗?带有后缀M的十进制值也是如此:

decimal testDecimal = 3.0M;
Run Code Online (Sandbox Code Playgroud)

然后,当涉及到其他后缀时,它开始让我感到困惑:

ulong bigOne = 2985825802805280508UL;
Run Code Online (Sandbox Code Playgroud)

ulong之前在测试中使用过,并且知道它u是"无符号"的,并且它的值是正常值的两倍.然后你再次得到U作为后缀,谷歌的文字就像谷歌说的那样.据我了解,"文字"是包含数字的值类型.但我不明白的是,即使没有后缀,为什么这个ulong工作呢?

ulong bigOne = 2985825802805280508;
Run Code Online (Sandbox Code Playgroud)

然后我尝试了不同的东西来理解后缀的重要性

byte testLong = 12312UL;
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为字节(254)的值太高而后缀不会将其转换为长变量.

为什么第一个单词(类型)不足以申报?第一个词应该足以告诉类型.最好的做法是始终为值赋予后缀吗?

c# declaration literals variable-declaration

24
推荐指数
2
解决办法
1737
查看次数

C#,如何将证书添加到HttpClientHandler?

我需要将数据发送到需要证书授权的web api.但我不知道如何将证书添加到.Net 4.5中的处理程序.这是代码:

// Import the certificate
X509Certificate2Collection certificates = new X509Certificate2Collection();
certificates.Import(pathToCertificate, password, X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

using (var handler = new HttpClientHandler() { })
{
    using (var client = new HttpClient(handler))
    {
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


        // Build the JSON
        string json = JsonConvert.SerializeObject(userData, Formatting.Indented);
        Console.WriteLine(json);

        var httpContent = new StringContent(json, Encoding.UTF8, "application/json");

        var processResult = await client.PostAsync(uriToServer, httpContent);
        var responseBody = processResult.Content.ReadAsStringAsync().Result;

        Console.WriteLine(responseBody);
        //return JsonConvert.DeserializeObject<string>(responseBody);
    }
}
Run Code Online (Sandbox Code Playgroud)

我搜索了谷歌,发现了一个"HttpClientHandler.ClientCertificates.Add",但那是.Net Core而不是4.5.

这是可能的HttpClient还是我必须使用HttpWebRequest类?

更新:

与"Peter …

c# ssl

6
推荐指数
1
解决办法
7308
查看次数

使用 EWS API 在其他邮箱中创建文件夹

我尝试在其他邮箱中创建一个联系人文件夹。由于 Powershell 无法执行此操作,因此我通过此 MSDN 站点下载了 ac# 示例:

https://code.msdn.microsoft.com/exchange/Exchange-2013-Create-35e4948c/view/Discussions#content

然后我将 createFolder_CS.cs 修改为:

    class Ex15_CreateFolder_CS
    {
    static ExchangeService service = Service.ConnectToService(UserDataFromConsole.GetUserData(), new TraceListener());

    static void Main(string[] args)
        {
        CreateFolder(service, "Test", WellKnownFolderName.MsgFolderRoot);

        Console.WriteLine("\r\n");
        Console.WriteLine("Press or select Enter...");
        Console.Read();
        }

    static void CreateFolder(ExchangeService service, string DisplayName, WellKnownFolderName DestinationFolder)
        {
        // Instantiate the Folder object.
        Folder folder = new ContactsFolder(service);

        // Specify the name of the new folder.
        folder.DisplayName = DisplayName;

        // Create the new folder in the specified destination folder.
        folder.Save(DestinationFolder);

        Console.WriteLine("Folder created:" + …
Run Code Online (Sandbox Code Playgroud)

c# impersonation exchangewebservices

4
推荐指数
1
解决办法
4194
查看次数

在html站点上的Node.js mysql显示表

我是node.js的新手,并尝试在html网站上显示一个简单的表格.这个表应该填充来自mysql select的数据(例如:select*from testtable).

但我真的不明白该怎么做.对于具有PHP背景的人,如何在nodejs中的HTML中显示某些sql内容?我知道git mysql nodejs wiki但它根本没用,因为这只是关于获取数据而不是在网页上显示它.

在nodeJS中做类似事情的最佳做法是什么?有一个容易理解的方式,还是我应该继续使用PHP?我真的很喜欢关于node.js的想法,但开始就像爬一个滑溜溜的悬崖.

我也买了一本关于它的书,但这本书从来没有深入到表达(因为这将是太多的信息.​​.....).所以我知道express,pug,serve-static,我能够提供一个简单的html.但就是这样,没有CRUD或REST,我付了50欧元.

编辑:我是否需要使用API​​或者是否正确使用Angular.js?

EDIT2:

C:\Users\user\node_test\CRUD2>node app.js
module.js:327
throw err;
^

Error: Cannot find module './routes'

at Function.Module._resolveFilename (module.js:325:15)

at Function.Module._load (module.js:276:25)

at Module.require (module.js:353:17)

at require (internal/module.js:12:17)

at Object.<anonymous> (C:\Users\user\node_test\CRUD2\app.js:2:14)
at Module._compile (module.js:409:26)

at Object.Module._extensions..js (module.js:416:10)

at Module.load (module.js:343:32)

at Function.Module._load (module.js:300:12)

at Function.Module.runMain (module.js:441:10)
Run Code Online (Sandbox Code Playgroud)

EDIT3:

C:\Users\user\node_test\CRUD2>node app.js
Express server listening on port 4300
C:\Users\user\node_test\CRUD2\routes\testtable.js:4
var query = connection.query('SELECT * FROM testtable',function(err,rows){
                    ^

TypeError: Cannot read property 'query' of undefined
at C:\Users\user\node_test\CRUD2\routes\testtable.js:4:29
at …
Run Code Online (Sandbox Code Playgroud)

html mysql node.js

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

appcompat-v7:28.0.0-beta01更新后破解

我是Android工作室的初学者,昨天安装了它.然后我创建了一个工作得很好的空项目.今天我不得不更新,现在我正在与该错误消息作斗争:

在此输入图像描述

如您所见,我已经包含了示例.我有什么想法可以解决这个问题吗?这里是完整的app.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "at.sumser.fateandlove"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0-beta01'

    implementation 'com.android.support:support-media-compat:26.1.0'
    implementation 'com.android.support:animated-vector-drawable:28.0.0-beta01'

    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation'com.google.android.gms:play-services-location:15.0.1'
}
Run Code Online (Sandbox Code Playgroud)

有趣的是,它告诉我在SDK为28时添加'com.android.support:support-media-compat:26.1.0'?有任何想法吗?

更新 这里也是build.gradle:

// Top-level build file where you can add configuration options common …
Run Code Online (Sandbox Code Playgroud)

android-appcompat android-studio

3
推荐指数
1
解决办法
2357
查看次数

函数不返回反转数组

作为C#的新手,我尝试用方法反转数组.但它不会返回反转阵列.我试了几个小时,但仍然没有得到它我做错了.整个过程是从我购买的"C#玩家指南 - 第2版"一书中吸取教训.不幸的是,课程的解决方案没有包含在书中.该Main方法是预定义的,应该像你看到的那样使用.

如果我在for循环中输出它54321,那就没问题了.但是正确的输出应该来自该PrintNumbers方法.而且存在问题,因为输出12345没有逆转

这是代码,请告诉我你是否看到了不好的东西.

class Program
{
    static void Main(string[] args)
    {
        int[] numbers = GenerateNumbers();
        Reverse(numbers);
        PrintNumbers(numbers);

        Console.ReadKey();
    }

    //Generate the array and return the numbers
    static int[] GenerateNumbers()
    {
        int[] temp;
        temp = new int[] { 1, 2, 3, 4, 5 };
        return temp;
    }

    //Reverse the numbers in the array
    static int[] Reverse(int[] numbersToSwap)
    {
        //Write array length in value to decrement later
        int numbersLenghtMax = …
Run Code Online (Sandbox Code Playgroud)

c# arrays return function

2
推荐指数
1
解决办法
820
查看次数

Eclipse Mars不会在Java 8 Update 71之后启动

我昨天安装了Java 8 Update 71,现在我的Eclipse没有启动.Windows只在鼠标上显示一个短加载符号,就是这样.在我使用Java 8 Update 66之前,一切正常.

所以我尝试用-clean参数打开它并设置路径变量.删除了Eclipse和整个workspace文件夹,但这并没有解决问题.然后我在windows软件面板中卸载了java软件包,现在唯一剩下的就是Java SE Development Kit 8 Update 66.然后我尝试启动Eclipse,它的工作原理!但我不明白为什么,因为Path Variable被设置为较新的J8u71 /bin文件夹.

现在我想知道,我应该再次尝试安装SDK 8u71还是不需要?自甲骨文表示它解决了一些安全问题......

java eclipse

1
推荐指数
1
解决办法
2808
查看次数