问题列表 - 第16866页

如何获取数组属性的类型?

我有这样的事情:

public class Foo
{
    public Bar[] Bars{get; set;}
}


public class Bar
{
    public string Name{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我开始反思:

PropertyInfo propertyInfo = typeof(Foo).GetProperty("Bars");
Run Code Online (Sandbox Code Playgroud)

到现在为止还挺好.我想更深入地反思:

Type type = _propertyInfo .PropertyType; // this gives me that the type is Bar[]
Run Code Online (Sandbox Code Playgroud)

typeBar[],但它不是可以反映出type去找物业Name.有没有办法找出没有数组的trype?或者另一种找到单一类型Bar的方法?

.net reflection

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

使用Commons-Email向Gmail发送电子邮件

Email email = new SimpleEmail();
String authuser = "......@gmail.com";
String authpwd = "*******";
// Very Important, Don't use email.setAuthentication()
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator(authuser, authpwd));
email.setDebug(true); // true if you want to debug
email.setHostName("smtp.gmail.com");

email.getMailSession().getProperties().put("mail.smtp.auth", "true");
email.getMailSession().getProperties().put("mail.debug", "true");
email.getMailSession().getProperties().put("mail.smtp.port", "465");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.port", "465");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.class",   "javax.net.ssl.SSLSocketFactory");
email.getMailSession().getProperties().put("mail.smtp.socketFactory.fallback", "false");
email.getMailSession().getProperties().put("mail.smtp.starttls.enable", "true");
email.setFrom("........@gmail.com", "SenderName");
email.setSubject("TestMail");
email.setMsg("This is a test mail?");
email.addTo(".............@gmail.com", "ToName");
email.send();
Run Code Online (Sandbox Code Playgroud)

它给出了以下例外

SEVERE: org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.gmail.com:465
Run Code Online (Sandbox Code Playgroud)

java email apache-commons-email

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

NS String比较因stringWithFormat而失败

我有两个具有相同值的NSStrings

这对我失败了:

if (button.controlName == controlName) {
        return button;
    }
Run Code Online (Sandbox Code Playgroud)

这工作:

if ([button.controlName compare: controlName] == NSOrderedSame) {
        return button;
    }
Run Code Online (Sandbox Code Playgroud)

这是在目标c中比较字符串的方式吗?或者第一个声明是否也有效?为什么第一个陈述失败了?我知道它适用于其他字符串.

它不起作用的字符串初始化如下:

button.controlName = [NSString stringWithFormat:@"controlName%d", i]
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsstring

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

NHibernate"非法访问加载集合"错误

这个错误的原因是什么?我的课程是课程,它有笔记.映射如下.任何的想法?

<bag name="Notes" table="NOTE" cascade="all">
      <key column="COURSEID"/>
      <one-to-many class="Server.Data.Note, Server.Data"/>
    </bag>
Run Code Online (Sandbox Code Playgroud)

nhibernate-mapping

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

typedef _W64 unsigned int UINT_PTR,*PUINT_PTR;

这究竟是什么意思?

typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
Run Code Online (Sandbox Code Playgroud)

这是否意味着*PUINT_PTR是指针(显然)而UINT_PTR不是指针?如果是这样,为什么叫它UINT_PTR?(我将其读作unsigned int指针,或指向unsigned int的指针)

谢谢

c++

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

您在哪里将全局变量放在WPF应用程序中?

PHP Web编程中,我总是创建一个单独的Output对象,在其中我可以放置必须从任何代码行获得的全局信息.

所以在WPF应用程序,我创建了下面的类来实现同样的功能,如变量ReturnToPageIdCode返回到另一个页面应该处理一些任务后返回的页面,我可以设置和获取价值的任何地方我想要的.

这很好用.

但是,我不禁想到在有状态的 WPF环境中,我正在使用这个单例输出对象重新创建轮子.

您在哪里放置应用程序范围的值在WPF应用程序中?有一些标准的地方可以做到这一点吗?

public class Output
{
    private Output output;

    private static Output instance;

    public string ReturnToPageIdCode { get; set; }

    public static Output GetInstance()
    {
        if (instance == null)
        {
            instance = new Output();
        }
        return instance;
    }

    public string GetTestMessage()
    {
        return "This is a global test message from the output singleton.";
    }
}
Run Code Online (Sandbox Code Playgroud)

c# wpf global-variables

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

SQL删除基于另一个表的行

这可能很容易,但是周一早上.我有两张桌子:

表格1:

Field        | Type             | Null | Key | Default | Extra
id           | int(32) unsigned | NO   | PRI | NULL    | auto_increment
group        | int(32)          | NO   |     | 0       |                
Run Code Online (Sandbox Code Playgroud)

表2:

Field     | Type             | Null | Key | Default | Extra
group     | int(32)          | NO   |     | 0       | 
Run Code Online (Sandbox Code Playgroud)

忽略其他字段...我想要一个SQL DELETE语句,它将删除Table1中存在等于Table1.group的Table2.group的所有行.因此,如果Table1的一行具有group = 69,那么当且仅当Table2中存在group = 69的行时才应该删除该行.

感谢您的任何帮助.

mysql sql

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

为什么gcc报告"隐含的函数声明'轮''?

我有以下C代码:

#include <math.h>

int main(int argc, char ** argv)
{
    double mydouble = 100.0;
    double whatever = round(mydouble);

    return (int) whatever;
}
Run Code Online (Sandbox Code Playgroud)

当我编译它时,我收到警告:

round_test.c: In function ‘main’:
round_test.c:6: warning: implicit declaration of function ‘round’
round_test.c:6: warning: incompatible implicit declaration of built-in function ‘round’
Run Code Online (Sandbox Code Playgroud)

我对C生锈了,但我认为#include将round()的声明带入了范围.我已经检查了我的ANSI标准(C99是我唯一的副本),它确认了math.h标题中存在round()函数.我在这里错过了什么?

编辑:编译器是Ubuntu上的GCC 4.3.2(intrepid,IIRC).运行gcc -E给出:

$ gcc -E round_test.c | grep round
# 1 "round_test.c"
# 1 "round_test.c"
# 2 "round_test.c" 2
    double whatever = round(mydouble);
Run Code Online (Sandbox Code Playgroud)

所以这个定义显然没有在标题中找到.

c gcc compiler-warnings

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

Java:组件中setPreferredSize()和setSize()方法之间的差异

好的,我阅读了Java文档,我无法弄清楚这两种方法之间的主要区别.有时我曾经使用过setSize(),有时候setPreferredSize(),有时一个人会做我想要的,有时候是另一个.

那么,两者之间的主要区别是什么?我应该使用哪一个JFramesJPanels

谢谢

java swing jpanel jframe

101
推荐指数
4
解决办法
11万
查看次数

sql-server,SQL Query中的IF语句

我在使用IF此sql-server查询中的语句时遇到问题.

我想要的是:

如果salesHeader.[Ship-to Name]不为null,我需要返回AS DeliveryName,如果它为null,则返回其他内容.

有没有办法if在查询中使用语句执行此操作?

SELECT
   poHeader.No_ AS PONumber, 
   poHeader.[Buy-from Vendor No_] AS VendorNumber, 
   poHeader.[Document Date] AS DocDate, 
   salesHeader.GiftMessage, 
   salesHeader.[Delivery Comment] AS DeliveryComment,                     
   salesHeader.[Shipment Date] AS DeliveryDate, 
   IF salesHeader.[Ship-to Name] IS NOT NULL 
      salesHeader.[Ship-to Name] AS DeliveryName
   ELSE
      poHeader.[Ship-to Name] AS DeliveryName
   END 
FROM         
    dbo.[Crocus Live$Purch_ orders for e-mailing] AS poForEmailing 
LEFT OUTER JOIN
    dbo.[Crocus Live$Purchase Header] AS poHeader ON poForEmailing.No_ = poHeader.No_ 
INNER JOIN
    dbo.[Crocus Live$Vendor] AS vendor ON poHeader.[Buy-from Vendor No_] …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server

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