小编Fil*_*urt的帖子

C# - Linq语句跳过最后X行

我有一个显示/隐藏行的动态表.

在这个变量中我跳过第一行,但我想跳过最后n行......

var allVisibleRows1 = myTbl.Rows.Cast<TableRow>().Where(row => row.Visible).Skip(1);
Run Code Online (Sandbox Code Playgroud)

(跳过1) 2 3 4 5 (跳过6) (跳过7)

这该怎么做?

.net c# linq asp.net

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

以特定格式将int转换为字符串

我有一个int,我想转换为特定格式的字符串.

例如,-1到-01:00

如果我有正数(即1到01:00),这很容易.我可以使用以下代码:

var time = 6;
var convertTime = "0" + time + ":00";
Run Code Online (Sandbox Code Playgroud)

输出:

06:00
Run Code Online (Sandbox Code Playgroud)

我不知道如何用负数实现相同.

 var time = -6;
 var convertTime = /* what to do here */ + time + ":00";
Run Code Online (Sandbox Code Playgroud)

期望的输出:

-06:00
Run Code Online (Sandbox Code Playgroud)

c#

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

获取表单的所有文本框,其名称按升序排列

我在一个表单中共有36个文本框,文本框的名称为txtBox1,txtBox2 ..... to txtBox36.其中一些textBox填写在form_load事件上.

我希望得到所有文本的盒子名称,它们是按升序排列的.

我尝试过的:

foreach (Control control in this.Controls)
{
    if (control is TextBox)
    {
        if (String.IsNullOrEmpty(control.Text))
        {
            for (int j = 1; j <= 36; j++)
            {
                MessageBox.Show(control.Name.ToString());
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它给出的是随机顺序

txtBox26
txtBox28
txtBox31
txtBox34
txtBox33
txtBox30
txtBox27
txtBox29
txtBox25
txtBox14
txtBox16
txtBox19
txtBox21
txtBox18
txtBox17
txtBox23
txtBox24
txtBox13
txtBox7
txtBox10
txtBox6
txtBox3
txtBox11
txtBox12
Run Code Online (Sandbox Code Playgroud)

c# sorting visual-studio-2013

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

找出字符串中最常见的 5 个单词

我和我的同事尝试制作一个单词计数器,从某个路径中查找 5 个最常见的单词并将它们输出到控制台。到目前为止,我们只设法制作了一个代码来搜索我们正在输入的单词以及它出现的次数。

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace wordcounter_2._0
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Bitte geben sie eine Keywort ein.");
            string patternWord = Console.ReadLine();
            Console.WriteLine("Bitte geben sie einen Pfad ein.");
            string Pfad = Console.ReadLine();
            try
            {
                StreamReader MyReader = new StreamReader(Pfad);
                string text = MyReader.ReadToEnd();
            }
            catch
            {
                Console.WriteLine("Bitte geben sie einen gültigen Pfad ein.");
            }
            string[] inputSentence = Console.ReadLine().Split();
            int count = 0;
            string pattern …
Run Code Online (Sandbox Code Playgroud)

c#

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

在win2k8上部署时,WCF VSTO客户端无法找到默认端点

我在Win2008R2终端服务器上创建并部署了一个WCF客户端(从VSTO Word Addin启动).执行时,将InvalidOperationException抛出WCF代理的默认构造函数an ,表明无法找到合同的默认端点.

部署到Win7 x64计算机时,相同的WCF客户端使用相同的.dll.config运行正常

我试图在PowerShell中创建一个实例并收到相同的错误.

如果在PowerShell中创建专用端点,我可以执行一个服务方法:

$binding = New-Object System.ServiceModel.BasicHttpBinding
$endpoint = New-Object System.ServiceModel.EndPointAddress("http://myserver:7777/CompanyService.svc")
$client = New-Object MyClient.CompanyServiceReference.CompanyServiceClient($binding, $endpoint)
$v = $client.Version()
Run Code Online (Sandbox Code Playgroud)

服务Web.config(部分)

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="false"/>
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="NoHttpSecurity" sendTimeout="00:03:00">
                <security mode="None" />
            </binding>
        </basicHttpBinding>
    </bindings>
    <services>
        <service name="CompanyService">
            <endpoint address="http://myserver:7777/mex" contract="IMetadataExchange" binding="mexHttpBinding" />
            <endpoint name="Version" address="http://myserver:7777/Version" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
            <endpoint name="CompanyList" address="http://myserver:7777/CompanyList" contract="MyService.ICompanyService" binding="basicHttpBinding" bindingConfiguration="NoHttpSecurity" />
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

MyClient.dll.config(部分)

<system.serviceModel>
    <bindings> …
Run Code Online (Sandbox Code Playgroud)

.net wcf vsto windows-server-2008

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

如何将日期时间格式化为GMT而不考虑区域设置?

我有一个日期时间存储在数据库中作为GMT.我需要将此日期时间格式化为字符串以及UTC的时区偏移量,例如:

DateTime date = DateTime.Parse("2012-03-15 12:49:23");
string dateAsString = date.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz");
Run Code Online (Sandbox Code Playgroud)

2012-03-15T12:49:23.000 + 00:00

此代码适用于我在英国的机器.当我将区域设置更改为其他时区时,例如Perth,我得到以下输出:

2012-03-15T12:49:23.000 + 08:00

我需要字符串输出始终以GMT表示时间.

c# timezone datetime

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

wp7上的蓝牙

我需要开发一个应用程序,它必须连接到蓝牙模块,我该怎么做?

bluetooth connect windows-phone-7

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

C#asp.net mvc用户名正则表达式

我正在寻找用户名的正则表达式

我想允许:

  • 只有ASCII
  • 只 - - 符号
  • minium 5个字符,最多15个字符

c# regex asp.net-mvc

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

以编程方式列出SQL Server的实例

我有代码来查找sql​​server的列表

 public static string[] GetSQLServerList()
        {
            SqlDataSourceEnumerator dse = SqlDataSourceEnumerator.Instance;
            DataTable dt = dse.GetDataSources();
            if (dt.Rows.Count == 0)
            {
                return null;
            }

            string[] SQLServers = new string[dt.Rows.Count];
            int f = -1;
            foreach (DataRow r in dt.Rows)
            {
                string SQLServer = r["ServerName"].ToString();
                string Instance = r["InstanceName"].ToString();
                if (Instance != null && !string.IsNullOrEmpty(Instance))
                {
                    SQLServer += "\\" + Instance;
                }
                SQLServers[System.Math.Max(System.Threading.Interlocked.Increment(ref f), f - 1)] = SQLServer;
            }
            Array.Sort(SQLServers);
            return SQLServers;
        }
Run Code Online (Sandbox Code Playgroud)

它工作正常(如果找到SQL Server),但遗憾的是它无法找到sql Express.

有谁有想法?

提前谢谢你

c# sql-server

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

MPMoviePlayerController生成本地视频文件的缩略图并存储它

我正在创建一个从服务器下载电影的应用程序,并将它们存储在NSDocumentDirectory中.

这很好用.

我想在每个单元格中添加每个影片前面的缩略图.

我的问题:

下载后如何从电影中生成缩略图(如此即时,无需先播放电影)?我想在NSDocumentDirectory中存储与jpg相同名称的缩略图.

我猜

-download movie并将其存储在NSDocumentDirectory中(有效)

-omeome加载电影在MPMoviePlayerController的内存中(不知道如何)

- 加载到内存中时,使用thumbnailImageAtTime(MPMovieTimeOptionNearestKeyFrame)生成缩略图(应该可以)

- 存储它(应该工作)

如果有人能帮助我......

谢谢

objective-c thumbnails mpmovieplayercontroller ipad ios

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