小编seb*_*ibu的帖子

如何测量函数运行的时间?

我想看一个函数运行多长时间.所以我在表单上添加了一个计时器对象,我出来了这段代码:

private int counter = 0;

// Inside button click I have:
timer = new Timer();
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
Result result = new Result();
result = new GeneticAlgorithms().TabuSearch(parametersTabu, functia);
timer.Stop();
Run Code Online (Sandbox Code Playgroud)

和:

private void timer_Tick(object sender, EventArgs e)
{
    counter++;
    btnTabuSearch.Text = counter.ToString();
}
Run Code Online (Sandbox Code Playgroud)

但这并不算什么.为什么?

.net c# performance timer stopwatch

39
推荐指数
8
解决办法
4万
查看次数

从Visual Studio生成类图

我想为我的visual studio项目生成一个带有关系的类图.我打开了我的解决方案,添加了一个新的ModelingProject,添加了一个新.classdiagram文件但是当我想将我的文件夹或我的类拖到图表布局上时,我得到了"不可用"的标志.

有没有人知道如何解决这个问题?

证明

diagram class-diagram visual-studio-2010

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

在C#中将多维数组转换为锯齿状数组

我有一个C#WCF webservice,由两个VB 6项目调用.目标VB项目正在向客户端VB项目发送一个多维数组.

我想将多维数组转换为锯齿状数组,但我没有运气.

如何才能找到我的对象[,]中的油脂数量,以便能够初始化锯齿状阵列?

我想按照这个问题的答案,但我的GetLength方法没有方法.

我试过了 :

int firstElement = astrManTfrLetters.GetLength(0);
int secondElement = astrManTfrLetters.GetLength(1);
Run Code Online (Sandbox Code Playgroud)

我卡在这里.

c# jagged-arrays multidimensional-array

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

Java Observer和Observable在应用程序之间无法正常工作

我有一个包含默认列表模型的主JFrame的应用程序.我希望如果我修改这些记录上的内容,第二个正在运行的应用程序会自动更新.

到目前为止,我有一个MainController类,它实现了监听器并覆盖了更新方法:

public class MainController implements ActionListener, Observer {
  public void update(Observable o, Object o1) {}
}
Run Code Online (Sandbox Code Playgroud)

和一个扩展Observable的简单类

public class Comanda extends Observable{}
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果我从第一个应用程序中删除一个记录,第二个列表不会更新.程序正在从文本文件中删除记录,但不更新默认列表模型.编辑或添加也存在同样的问题.

我尝试在更新方法中添加"reloadList()",但这不起作用.想法?

java observable observer-pattern

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

图中2个节点之间的所有路径

我必须进行一个不知情的搜索(广度优先搜索)程序,它接受两个节点并返回它们之间的所有路径.

public void BFS(Nod start, Nod end) {
            Queue<Nod> queue = new Queue<Nod>();
            queue.Enqueue(start);
            while (queue.Count != 0)
            {
                Nod u = queue.Dequeue();
                if (u == end)  break;
                else
                {
                    u.data = "Visited";
                    foreach (Edge edge in u.getChildren())
                    {
                        if (edge.getEnd().data == "")
                        {
                            edge.getEnd().data = "Visited";
                            if (edge.getEnd() != end)
                            {
                                edge.getEnd().setParent(u);
                            }
                            else
                            {
                                edge.getEnd().setParent(u);
                                cost = 0; 
                                PrintPath(edge.getEnd(), true);
                                edge.getEnd().data = "";
                                //return;
                            }
                        }
                        queue.Enqueue(edge.getEnd());
                    }
                }
            }
        }
Run Code Online (Sandbox Code Playgroud)

我的问题是,我只获得两条路径,而不是所有路径,我不知道在我的代码中编辑什么来获取它们.我的问题输入基于这张地图:地图

c# algorithm graph graph-algorithm

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

SQL Server:更新树中的列

我想更新树中的列.我想出了以下声明:

WITH q AS (
    SELECT t1.*
    FROM buss_item t1
    WHERE t1.id_item = 218

    UNION ALL

    SELECT t2.*
    FROM buss_item t2
    JOIN q ON t2.parent_id = q.id_item
)
UPDATE q
SET default_item = 0
Run Code Online (Sandbox Code Playgroud)

但是我收到一个错误:

派生表'q'不可更新,因为派生表的列是派生的或常量的.

有关如何修复此更新的任何想法?

sql sql-server tree database-design sql-update

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

WCF和JSON绑定

我正在尝试创建一个返回json的wcf服务.我的配置文件有一些问题,我也不知道如何测试它.

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="ContactLibraryJSON.ContactLibrary">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="JSONEndpointBehavior"
          contract="ContactLibraryJSON.IContactServiceJSON" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://192.168.1.31/ContactLibraryJSON" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="JSONEndpointBehavior">
          <webHttp/>
        </behavior>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to …
Run Code Online (Sandbox Code Playgroud)

wcf json wcf-binding wcf-rest

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

从unity3D消耗WCF

我有一些wcf webservices,我在IIS上托管在localhost上.我希望能够从Unity3d访问它们但我在播放场景时收到以下错误:

InvalidOperationException: Client endpoint configuration 'BasicHTTPEndpoint' was not found in 0 endpoints.
System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig)
System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ChannelFactory`1[IUnityStore]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName)
System.ServiceModel.ClientBase`1[TChannel]..ctor (System.String endpointConfigurationName)
UnityStoreClient..ctor (System.String endpointConfigurationName)
firstCall.Start () (at Assets/Scripts/firstCall.cs:8)
Run Code Online (Sandbox Code Playgroud)

Web服务实例化如下:

UnityStoreClient uc = new UnityStoreClient("BasicHTTPEndpoint");
uc.Open(); //i don't know if i need this ?????
UnityStoreLibrary.User[] users = uc.GetAllUsers("1",null);
for (int i=0;i<users.Length;i++)
    Debug.Log("username = " + users[i].username);
Run Code Online (Sandbox Code Playgroud)

我的脚本文件夹中有一个配置文件,但我不知道我是否应该使用它.我使用svcutilVisual Studio 2010 …

c# wcf unity-game-engine

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

EPPlus 设置默认工作表

我正在使用 EPPlus v4.1 在 C# 中生成一个 excel 文件。

有没有办法将特定工作表设置为默认工作表?(当用户打开导出的文件时,应显示该工作表)

我在ExcelWorkbookExcelWorksheets类上找不到方法或属性。

c# excel epplus epplus-4

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

WCF和SQL错误

我正在构建一个简单的WCF服务,它必须从SQL表返回一些数据.当我运行该项目时,我收到以下错误:

无法调用该服务.可能的原因:服务离线或无法访问; 客户端配置与代理不匹配; 现有代理无效.有关更多详细信息,请参阅堆栈跟踪.您可以尝试通过启动新代理,还原到默认配置或刷新服务来进行恢复

如果我评论所有SQL部分并发送一些静态数据一切正常.这是令我头疼的功能:

public Client getClient(int idClient)
{
    Client c = new Client();
    SqlConnection sql = new SqlConnection(@"Data Source=GRIGORE\SQLEXPRESS;Initial Catalog=testWCF;Integrated Security=True");
    sql.Open();

    SqlCommand cmd = new SqlCommand("Select * from Clienti where id = " + idClient);
    SqlDataReader dr = cmd.ExecuteReader();
    if (dr.Read())
    {
        c.idClient = int.Parse(dr["id"].ToString());
        c.numeClient = dr["nume"].ToString();
    }

    dr.Close();
    sql.Close();

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

想法?

c# sql wcf

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