小编gbk*_*gbk的帖子

继承初学者

我刚刚开始学习java,所以现在我读到了继承这种可能性,所以尝试创建必须创建对象框的类.并使用继承实现新属性来创建对象.我尝试将每个类放在单独的文件中,因此在创建类之后,尝试使用它

public static void main(String[] args)
Run Code Online (Sandbox Code Playgroud)

所以类继承:

 public class Inheritance {
double width;
double height;
double depth;
Inheritance (Inheritance object){
    width = object.width;
    height = object.height;
    depth = object.depth;
}
Inheritance ( double w, double h, double d){
    width = w;
    height = h;
    depth = d;
}
Inheritance (){
    width = -1;
    height = -1;
    depth = -1;
}
Inheritance (double len){
    width=height=depth=len;
}
double volumeBox (){
    return width*height*depth;
}
class BoxWeight extends Inheritance {
    double weight;
    BoxWeight (double …
Run Code Online (Sandbox Code Playgroud)

java inheritance

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

WPF:从具有自定义行为的类绑定到属性

使用 WPF、C#、VS 2012

尝试使用 WPF 为 UI 实现一些自定义行为。当前创建继承自的类Behavior<FrameworkElement>

想法:在 UI 上创建一个用于输入名称的区域(我使用文本框)-另一个区域(矩形)-按下并查看带有来自上一个字段的数据的一些操作。

做了什么:

实现想法的类(带有行为的类)

class SayHello: Behavior<FrameworkElement>
{
    public string Words { get; set; }
    protected override void OnAttached()
    {
        AssociatedObject.MouseLeftButtonUp += OnMouseClick;
    }
    private void OnMouseClick(object sender, 
                System.Windows.Input.MouseButtonEventArgs e)
    {
        MessageBox.Show(string.Format("hello , {0}", Words));
    }
    protected override void OnDetaching()
    {
        AssociatedObject.MouseLeftButtonUp -= OnMouseClick;
    }        
}
Run Code Online (Sandbox Code Playgroud)

XAML:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
    xmlns:local="clr-namespace:CH08.MovingCircle"
    x:Class="CH08.MovingCircle.MainWindow"
    Title="MainWindow" Height="350" Width="525">
<Canvas>
    <Border Canvas.Top="220" BorderBrush="Black" 
            BorderThickness="2">
        <TextBox x:Name="_enteredWords" Width="200"/>
    </Border>

    <Rectangle Stroke="Blue" Canvas.Top="250" Fill="Aquamarine" …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml binding triggers

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

如何在Facebook上检测默认头像?

如何检测这样的链接默认的头像:https://graph.facebook.com/'.$id.'/picture?type=large?它是从特殊准备的配置文件中获取头像(男/女)然后通过例如md5()进行比较的唯一方法吗?

很难相信这是唯一的方法.

facebook avatars avatar facebook-graph-api ios

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

如何隐藏Form而不是关闭它

尝试隐藏表单而不是关闭它,使用

    private void Playlist_FormClosed(object sender, FormClosedEventArgs e)
    {
        if (e.CloseReason == CloseReason.FormOwnerClosing) //if closed by aplication
        {
            this.Close();
        }
        if (e.CloseReason == CloseReason.UserClosing) //if closed by user
        {
            this.Hide();
        }
    }
Run Code Online (Sandbox Code Playgroud)

但如果用户点击关闭,它仍然关闭它.

.net c# winforms

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

使用 T-SQL 创建表 - 在对象资源管理器中看不到创建的表

使用微软 SQL

尝试使用 T-SQL 语言创建表。代码非常简单,执行成功,但我在对象资源管理器中没有看到创建的表。尝试重新启动/重新连接/刷新/重新执行 - 结果相同 - 看不到此表。也尝试手动执行(通过在对象资源管理器中的树中右键单击鼠标 - 一切正常 - 可以看到刚刚创建的表)。

代码:

USE tempdb 
    IF OBJECT_ID('dbo.Employees','U') IS NOT NULL
DROP TABLE dbo.Employees;
CREATE TABLE dbo.Employees
(
    empid INT NOT NULL,
    firstname VARCHAR(30) NOT NULL,
    lastname VARCHAR(30) NOT NULL,
    hiredate DATE NOT NULL,
    mgrid INT NULL,
    ssn VARCHAR(20) NOT NULL,
    salary MONEY NOT NULL
);
Run Code Online (Sandbox Code Playgroud)

截屏

在此处输入图片说明

觉得这个问题很简单,还是试着找答案,稍微堆叠一下。为什么我没有看到刚刚创建的表?此代码对于创建表是否正确?

sql t-sql sql-server

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

AES128 CTR 加密与 iv

我想用 iv 和 key 实现 AES128 CTR。我正在寻找如何以最好的方式做到这一点而不是重新发明轮子的建议。

我找到了这个RNCryptor的好库,但看起来那里不支持这个 aes。

我也测试了这种方法,但看起来这不是点击率。

编辑


我使用了 @zaph 的 zpproach

NSData *result = [NSData cryptData:dataStr
                         operation:kCCEncrypt
                              mode:kCCModeCTR
                         algorithm:kCCAlgorithmAES128
                           padding:ccNoPadding
                         keyLength:kCCKeySizeAES128
                                iv:ivHex
                               key:keyHex
                             error:&error];
Run Code Online (Sandbox Code Playgroud)

但收到CCCryptorCreate status: -4305

刚刚在源码中找到的

@constant kCCUnimplemented Function not implemented for the current algorithm.

关联

encryption aes ios commoncrypto

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

如何:*.csv - > line - > someArray - >修改

现在尝试创建一些代码,从CSV文件中获取一个字符串并将其与某些条件进行比较.如果此字符串超过标准,则将其分为4个部分 - 将每个部分放在数组中,而不是从中获取一些新值TextBox并进行更改.

目前我在点,当需要划分选定的字符串.准备一些代码,但不要只获得分开的数组System.string[]

 try
        {
            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite); 
            StreamReader sr = new StreamReader(fs); //open file for reading
            string[] line = sr.ReadToEnd().Split(new string[] { Environment.NewLine }, 
                                             StringSplitOptions.None); //read file to the end an divide it 
            sr.Close(); //close stream
            foreach (var l in line) //check each line for criteria
            {
                if (l.Contains(dateTimePicker1.Text.ToString() + eventNameUpdateTextBox.Text.ToString()))
                {
                    try
                    {
                        string[] temp = { "", "", "", "", };// i always have just 4 …
Run Code Online (Sandbox Code Playgroud)

c# arrays string winforms

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

委派它是如何工作的

使用C#,.Net Framework 4.5,visual Studio 2012

经过一些理论尝试在C#中创建一些委托.

目前创建下一个代码

namespace SimpleCSharpApp
{
public delegate void MyDelegate();
class Program
{   
    private static string name;
    static void Main(string[] args)
    {
        //my simple delegate
        Console.WriteLine("Enter your name");
        name = Console.ReadLine().ToString();
        MyDelegate myD;
        myD = new MyDelegate(TestMethod);

        //Generic delegate
        Func<Int32, Int32, Int32> myDel = new Func<Int32, Int32, Int32>(Add);
        Int32 sum = myDel(12, 33);
        Console.WriteLine(sum);
        Console.ReadLine();

        //call static method from another class
        myD = new MyDelegate(NewOne.Hello);
    }
    public static void TestMethod()
    {
        Console.WriteLine("Hello {0}", name); …
Run Code Online (Sandbox Code Playgroud)

c# delegates visual-studio-2012

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

在xCode中找不到方法定义

使用xCode 5.1,Objective C

刚开始尝试使用Objective C,编写一个简单的程序,并得到一些警告: Method definition for "some method" not found...

我正在查看我的代码,我在实现文件(.m)屏幕中看到了方法.

在此输入图像描述

我知道 - 看到很多类似的问题:

  • 这里 - 信件案例的差异 - 检查一切都没问题
  • 这里 - 调用.m文件中不存在的方法 - 检查 - 存在
  • 这里 - 和上一个问题一样.题
  • 在这里 - 怪异/非标准设置Apple - 一切都好
  • 这里 - 不正确的实施
  • 这里 - 错过参数,所以执行不正确
  • 和其他相同的错误......

所以根据这篇文章,我认为问题是或缺少声明/实现或一些语法错误

检查我的代码看起来一切正常.


声明 - 在.h文件中

//- mean non static method
//(return type) Method name : (type of var *) name of var
- (void)addAlbumWithTitle : (NSString *) title
//global name of var : (type of var *) …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

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

nil __weak self - 为什么会发生?

我想在块中使用弱自我,但是在块中这个 weakSelf 变为 nil

刚刚创建,在阻止之前(尝试使用不同的变体) - 看起来一切正常

在此处输入图片说明

但后来在块中 - 每个变体都为零

在此处输入图片说明

做错了什么?谁能解释一下?

编辑

SPHVideoPlayer *videoPlayer = [[SPHVideoPlayer alloc] initVideoPlayerWithURL:urlToFile];
[videoPlayer prepareToPlay];
Run Code Online (Sandbox Code Playgroud)

初始化

#pragma mark - LifeCycle

- (instancetype)initVideoPlayerWithURL:(NSURL *)urlAsset
{
    if (self = [super init]) {
        [self initialSetupWithURL:urlAsset];
    }
    return self;
}

- (void)initialSetupWithURL:(NSURL *)url
{
    NSDictionary *assetOptions = @{ AVURLAssetPreferPreciseDurationAndTimingKey : @YES };
    self.urlAsset = [AVURLAsset URLAssetWithURL:url options:assetOptions];
}
Run Code Online (Sandbox Code Playgroud)

还有使用块的方法

- (void)prepareToPlay
{
    __weak typeof(self) weakSelf = self;
    __weak SPHVideoPlayer *weakSealf2 = self;
    NSArray *keys = @[@"tracks"];
    [self.urlAsset loadValuesAsynchronouslyForKeys:keys completionHandler:^{ …
Run Code Online (Sandbox Code Playgroud)

null block objective-c weak ios

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