小编Has*_*aan的帖子

如何在Visual Studio 2013中启用C#6.0功能?

我正在阅读C#6.0中介绍的最新功能,并且只是按照自动属性初始化程序的示例,

class NewSample
{
    public Guid Id { get; } = Guid.NewGuid();
}
Run Code Online (Sandbox Code Playgroud)

但我的IDE无法识别语法.

我想知道如何在Visual Studio 2013中启用C#6.0.我使用的Target框架是4.5.1.

c# visual-studio visual-studio-2013 c#-6.0

198
推荐指数
3
解决办法
12万
查看次数

当分配给命令的连接处于挂起的本地trans时,ExecuteReader需要命令才能具有事务

我必须在单个事务中插入两个表,下面要执行的查询.其次在SqlDataReader上获取异常read = comm.ExecuteReader();

public void SqlExecuteNonQuery(Customer obj)
{
  //string query = "DECLARE @_customerID int ";
  string query1 = "INSERT INTO customer (customerName,customerSex,Email) VALUES ('" + obj.name + "','" + obj.sex + "','" + obj.Email + "') ";
  //string query2 = "SET @_customerID =@@identity ";
  string query3 = "INSERT INTO customerDetails(customerID,customerAddress,customerPhone) VALUES (" + obj.id + ",'" + obj.address + "','" + obj.phone + "') ";

  string CS = ConnectionName;

  using (SqlConnection conn = new SqlConnection(CS))
  {
     conn.Open(); …
Run Code Online (Sandbox Code Playgroud)

c# ado.net

15
推荐指数
2
解决办法
3万
查看次数

如何使标签文字下划线?

如何在WPF中创建Label文本Underline?我被困了,找不到下划线的任何财产:

<Label Name="lblUserName"
       Content="Username"
       FontSize="14" FontWeight="Medium" />
Run Code Online (Sandbox Code Playgroud)

wpf xaml label underline

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

如何处理angularjs中的回调?

我有一个注册机制,其中rootscope变量通过服务发送.成功后,它会更新该$rootScope.success字段.但angularjs服务依赖于回调.服务更新了rootscope.success,但函数顺序执行代码.

我如何等待服务完成其响应然后进一步处理?

.controller('RegisterAccountCtrl', function ($scope,$rootScope,registerUser,$location) {

    $rootScope.success = false;
    $scope.registration = $rootScope.registration;

$scope.getEnterGeneratedCode = function(){
        $rootScope.registration = $scope.registration;
        registerUser.registerUser();
        if($rootScope.success){
           $location.path('/confirm');
        }
}
Run Code Online (Sandbox Code Playgroud)

内部服务

.service('registerUser',function($http,$rootScope,$ionicLoading){
    this.registerUser = function(){
        $ionicLoading.show();
        $http({
            method: 'POST',
            datatype:'json',
            data:{obj:$rootScope.registration},
            url: 'http://localhost/LoginService.asmx/CreateUser',
            contentType: "application/json; charset=utf-8",
            cache: false
        }).success(function (data, status, headers, config){
            if (status == '200') {
                var obj = data;
                $rootScope.success = true;
                $ionicLoading.hide();
                //alert(obj);
            }
        }).error(function (data, status, headers, config){
            $ionicLoading.hide();
        });
    };

 return this;
})
Run Code Online (Sandbox Code Playgroud)

javascript callback angularjs

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

表行上的Vuejs转换

我正在尝试在html表行(vue.js)上进行转换(动画)但没有成功.这是完整的例子

  new Vue({
    el: '#data',
    data: {
      items: [
        {
          data: 'd1',
          more: false
        },
        {
          data: 'd2',
          more: false
        },
      ]
    }

  });
Run Code Online (Sandbox Code Playgroud)
.fade-enter-active, .fade-leave-active {
        transition: opacity 2s
      }
      .fade-enter, .fade-leave-to  {
        opacity: 0
      }
Run Code Online (Sandbox Code Playgroud)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.2/vue.min.js"></script>


    <div class="container-fluid" id="data">
      <br>
      <br>
      <table border="1" class="table table-bordered">
        <thead class="thead-inverse">
          <tr>
            <th>anim</th>
          </tr>
        </thead>
        <tbody>  
        <template v-for="item, k in items">
          <tr>
            <td><button @click="item.more = !item.more" type="button" 
                         v-bind:class="[item.more ? 'btn-danger' : 'btn-primary']" class="btn">Show the hidden row</button></td>
          </tr>

          <transition …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuejs2

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

如何在用户使用c#在asp.net中注销时清除浏览器缓存?

作为asp.net中的新功能.在我的asp.net应用程序中log off on click event使用函数的成员身份ClearSession(),但是如果我在浏览器上单击后退按钮,它会在转发到缓存页面后出现问题.如何在浏览器中清除缓存,以便用户在未登录时无法查看其配置文件

protected void ClearSession()
{
    FormsAuthentication.SignOut();
    Session.Clear();
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ExpiresAbsolute = DateTime.UtcNow.AddDays(-1d);
    Response.Expires = -1500;
    Response.CacheControl = "no-Cache";
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net cache-control

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

如何将域名映射到Websocket服务器(ws)nodejs?

我一直在研究 websocket 实现,我只是想将其托管到公共领域。我有域名“www.abc.com”和端口 80,但找不到映射它们的方法。

我正在使用 nodejs 中的“ws”包

我的示例实现就像

//require our websocket library 
var WebSocketServer = require('ws').Server;

//creating a websocket server at port 55454 
var wss = new WebSocketServer({port: 55454}); //How do i map 'www.abc.com' 

//all connected to the server users 
var users = {};

//when a user connects to our sever 
wss.on('connection', function(connection) { .... });
Run Code Online (Sandbox Code Playgroud)

javascript websocket node.js

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

异常行为,找不到名称“Array”

我正在尝试使用 Angular 7 中的数组功能,但我遇到了错误:cannot find name 'Array'. 同样,我无法使用简单的数组方法,如推送和弹出。

这是样本

Angular7 不允许我初始化变量,例如:

list: Array<number> = [1, 2, 3];

根本原因是什么以及如何解决?

更新:tsconfig.js

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

此外,代码编译没有错误。

代码编译成功

神秘的解决方案:我设法通过更新 Visual Studio 代码来解决编译错误。该问题尤其与 Visual Studio 代码更新有关。

typescript ecmascript-6 visual-studio-code angular

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

如何从ComboBox的SelectedItem获取密钥?

我想获得的关键SelectedItemComboBox,但不弄清楚如何让我做的是代码,

void CboBoxSortingDatagridview(ComboBox sender)
{
    foreach (var v in DictionaryCellValueNeeded)
    {
        if (!DictionaryGeneralUsers.ContainsKey(v.Key) && v.Value.RoleId == Convert.ToInt32(((ComboBox)sender).SelectedItem)) // here getting value {1,Admin} i want key value which is 1 but how?
        {
            DictionaryGeneralUsers.Add(v.Key, (GeneralUser)v.Value);
        }
    }
    dataGridViewMain.DataSource = DictionaryGeneralUsers.Values;
}  
Run Code Online (Sandbox Code Playgroud)

我用这种方式绑定了组合框,

cboRolesList.DataSource = new BindingSource(dictionaryRole, null);  
cboRolesList.DisplayMember = "Value";  
cboRolesList.ValueMember = "Key";
Run Code Online (Sandbox Code Playgroud)

c# combobox keyvaluepair

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

OneHotEncoder categorical_features已贬值,如何转换特定列

我需要将独立字段从字符串转换为算术符号。我正在使用OneHotEncoder进行转换。我的数据集有许多独立的列,其中一些是:

Country     |    Age       
--------------------------
Germany     |    23
Spain       |    25
Germany     |    24
Italy       |    30 
Run Code Online (Sandbox Code Playgroud)

我必须像编码国家列

0     |    1     |     2     |       3
--------------------------------------
1     |    0     |     0     |      23
0     |    1     |     0     |      25
1     |    0     |     0     |      24 
0     |    0     |     1     |      30
Run Code Online (Sandbox Code Playgroud)

我通过使用OneHotEncoder成功获得了欲望的转化

#Encoding the categorical data
from sklearn.preprocessing import LabelEncoder

labelencoder_X = LabelEncoder()
X[:,0] = labelencoder_X.fit_transform(X[:,0])

#we are dummy encoding as the machine learning algorithms will be …
Run Code Online (Sandbox Code Playgroud)

python machine-learning one-hot-encoding

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