小编qJa*_*ake的帖子

VB.NET是否支持属性上的自动getter和setter?

在C#中,我可以这样做:

public string myProperty { get; private set; }
Run Code Online (Sandbox Code Playgroud)

这被称为"自动吸气器/定位器"(据我所知).VB.NET是否支持这些?到目前为止,凭借我的属性,我所能做的就是:

Public Property myProperty As String
    Get
        Return String.Empty
    End Get
    Private Set(ByVal value As String)
        somethingElse = value
    End Set
End Property
Run Code Online (Sandbox Code Playgroud)

这是非常笨重的.

所以...有更好的方法吗?

vb.net properties c#-to-vb.net

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

获取包括HTML的页面选择?

我正在编写Chrome扩展程序,我想知道是否可以获取特定选项卡的选定文本,包括基础HTML?因此,如果我选择一个链接,它也应该返回<a>标记.

我试着查看上下文菜单事件对象(是的,我正在使用上下文菜单),这就是回调所带来的全部内容:

editable : false
menuItemId : 1
pageUrl : <the URL>
selectionText : <the selected text in plaintext formatting, not HTML>
Run Code Online (Sandbox Code Playgroud)

它还返回一个Tab对象,但其中没有任何内容非常有用.

所以我在这里不知所措.这甚至可能吗?如果是这样,你可能会有任何想法.谢谢!:)

google-chrome google-chrome-extension

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

实体框架4:所选存储过程不返回任何列

在我的SP中,我混合了静态SQL和动态SQL:

declare @result table
(
 RowNum bigint,
 Id_and_Title varchar(max),
 DaysLeft int,
 cat_id int
);
Run Code Online (Sandbox Code Playgroud)

然后,在动态SQL中,我将结果插入到该表中:

DECLARE @TSQL NVARCHAR(max);
SET @TSQL = ......
Run Code Online (Sandbox Code Playgroud)

(我使用print @TSQL所以我确定查询没问题)

insert into @result
EXECUTE sp_executesql @TSQL

select * from @result
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试在VS 2010 Ultimate中导入taht SP时,我会看到标题中提到的消息.是什么导致的?很多次我发生了这个错误,但我仍然不知道是什么原因引起的

t-sql stored-procedures entity-framework-4

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

将字典从一种类型转换为另一种类型

如何将a转换Dictionary(Of TypeA, TypeB)Dictionary(Of TypeC, TypeD)?转换时有一个隐式转换(假设第二个字典是String, String),所以这个过程应该是自动的,对吧?我只是无法想出一个优雅的方法来做到这一点.

语言是VB.NET,但是如果你对它感觉更舒服,我可以阅读和转换C#.

.net generics dictionary types

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

防止文本框因快速更新而滞后

给出以下示例代码:

new Thread(() =>
{
    for(int i = 0; i < 10000; i++)
    {
        Invoke((MethodInvoker)() => 
        {
            myTextBox.Text += DateTime.Now.ToString() + "\r\n";
            myTextBox.SelectedIndex = myTextBox.Text.Length;
            myTextBox.ScrollToCarat();
        });
    }
}).Start();

当您运行此代码时,在循环和线程终止后,文本框仍在更新(可能是因为缓冲的Invokes).我的应用程序使用类似的逻辑来填充文本框,我遇到了同样的问题.

我的问题是:如何尽可能快地填写此文本框,每次仍然滚动到底部,然后减少/消除这种滞后?

c# winforms

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

如何从多个可能的范围中获取单个随机数?

我希望能够从n个可能的范围生成(伪)随机数,其中范围是x, yx < y.例如,执行此代码:

for(int i = 0; i < 10; i++)
{
    Console.Write(Random.NextRanges(new Range(1, 6), new Range(10, 16), new Range(20, 31)) + " ");
}
Run Code Online (Sandbox Code Playgroud)

会产生类似的东西:

3 12 5 22 1 27 29 5 10 24
Run Code Online (Sandbox Code Playgroud)

该方法的签名NextRanges是:

public static int NextRanges(params Range[] ranges)
Run Code Online (Sandbox Code Playgroud)

Range定义为:

public struct Range
{
    public int X;
    public int Y;

    public Range(int x, int y)
    {
        if (x >= y) throw new ArgumentException("x must be …
Run Code Online (Sandbox Code Playgroud)

c# random

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

自动发布使用VS2017构建的NuGet包

Visual Studio 2017中的新功能是能够在构建时为某些目标类型生成NuGet包(即,.NET Standard 2.0我正在使用的).

这很好用,.nupkg文件是在成功构建时生成的.

但是,我无法弄清楚如何将构建的包自动发布到我们的本地存储库.

我已经尝试了一个后期构建事件:

nuget push -Source https://my.nuget.server/nuget/ "C:\Source\MyProject\bin\Release\MyProject.1.0.0.nupkg"
Run Code Online (Sandbox Code Playgroud)

但这提出了两个问题:

  1. 包的名称包括版本号,这不能作为构建后的事件变量,因此我不能说,例如,nuget push $(NugetPackage).我也无法找出能够有效获得包名称的宏/变量组合.
  2. 自动NuGet打包过程发生在构建后事件之后,因此在构建后,包甚至尚未生成!

微软提供了这种kick-ass自动NuGet包装,但无法将其推送到本地存储库(或者看起来如此)!

有没有人得到这个工作?我错过了什么吗?有解决方法吗?这件事正在进行吗?

nuget-package visual-studio-2017 .net-standard

7
推荐指数
2
解决办法
3940
查看次数

如何设置DropShadowEffect的不透明度?

我有一个带边框的WPF项目使用以下样式.计划是当鼠标移过边界时使发光效果淡入淡出,并在离开时淡出淡出效果.

<Style x:Key="BorderGlow" TargetType="Border">
    <Style.Resources>
        <Storyboard x:Key="GlowOn">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(DropShadowEffect.Opacity)">
                <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="GlowOff">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(DropShadowEffect.Opacity)">
                <SplineDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Style.Resources>

    <Setter Property="CornerRadius" Value="6,1,6,1" />
    <Setter Property="BorderBrush" Value="{StaticResource SelectedBorder}" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Background" Value="{StaticResource DeselectedBackground}" />
    <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
    <Setter Property="TextBlock.Foreground" Value="{StaticResource SelectedForeground}" />

    <Setter Property="RenderTransform">
        <Setter.Value>
            <RotateTransform Angle="90"/>
        </Setter.Value>
    </Setter>

    <Setter Property="Effect">
        <Setter.Value>
            <DropShadowEffect ShadowDepth="0" BlurRadius="8" Color="#FFB0E9EF"/>
        </Setter.Value>
    </Setter>

    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">

            <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource GlowOn}"/>
            </Trigger.EnterActions>

            <Trigger.ExitActions>
                <BeginStoryboard …
Run Code Online (Sandbox Code Playgroud)

wpf animation effects opacity storyboard

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

给定边界框和一条线(两个点),确定该线是否与框相交

给定一个边界框,在3D空间中定义像bounds.min.(x/y/z),bounds.max.(x/y/z)和两个点(表示为Vector3对象),如何确定两个点所形成的线是否与边界框相交?

c# math vector c#-2.0

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

如何强制 ReSharper 始终将第一个参数与方法放在同一行?

在 ReSharper 中,我打开了“Wrap Long Lines”,并且所有“Wrap Parameters”选项都设置为“Chop if long”。

如果我有这样一行代码:

DisplayMessage("This is a really long string that cuts off the screen ...", type, item);
Run Code Online (Sandbox Code Playgroud)

ReSharper 希望像这样格式化该行:

DisplayMessage(
    "This is a really long string that cuts off the screen ...",
    type,
    item);
Run Code Online (Sandbox Code Playgroud)

但我希望它像这样格式化:

DisplayMessage("This is a really long string that cuts off the screen ...",
               type,
               item);
Run Code Online (Sandbox Code Playgroud)

这可能吗?我意识到是因为第一个参数是长字符串,所以它想把它放在自己的行上,但我更喜欢切碎的参数与左括号对齐。

就像我需要一个[ ] Don't put the first parameter on its own line选择。

c# resharper resharper-10.0

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