可能重复:
C#/ .NET中只有名称空间的类可见性?
我想要的是拥有一个只能在同一命名空间内的其他类访问的类,而不必将命名空间放在它自己的程序集中.
有没有理由在C#中这是不可能的?
编辑:我已经改变了一点问题,因为编译器告诉我这private是不允许的.谁能告诉我这个的原因?
我需要将一个整数数组(基本上是一个2 d数组)传递给root的所有处理器.我在C程序中使用MPI.如何声明2 d数组的MPI数据类型以及如何发送消息(我应该使用广播还是分散)
解析器:查询包含XXXXXName参数,该参数未声明.(msmgdsrv)
我不知道为什么我一直收到这个错误.当我在查询设计器中更改MDX并尝试从查询设计器中清除时,会发生这种情况.
奇怪的是参数DOES存在,我可以在数据集对话框的参数部分看到它.在我对查询做任何其他事情之前,我正在创建它.
我想使用JavaScript打印网页.但我不想打开页面作为弹出窗口.如何使用JavaScript window.print方法直接打印像'mypage.aspx'这样的网页而不将其打开为弹出窗口?
条件是'我不想为此使用任何ActiveX'
这是我想要尝试的:
var printWindow, printData; printWindow = window.open("", "printVersion", "menubar,scrollbars,width=640,height=480,top=0,left=0");
printData=document.getElementById("lblReport").innerHTML; printWindow.document.write(printData);
printWindow.document.close();
printWindow.print();
Run Code Online (Sandbox Code Playgroud) 我想知道是否应该改变我的一个项目的软件架构.
我正在为一个项目开发软件,其中双方(实际上是主机和设备)使用共享代码.这有助于共享数据,例如枚举可以存储在一个中心位置.
我正在使用我们称之为"通道"的设备和主机之间传输数据.每个通道必须在设备和主机端实现.我们有不同类型的通道,普通通道和传输测量数据的特殊通道.
我当前的解决方案在抽象基类中具有共享代码.从那里开始,代码在双方之间分开.事实证明,在某些情况下,当我们共享代码但我们无法共享代码时,我们必须在每一方面实现它.
DRY的原则(不要重复自己)说你不应该有两次代码.
我的想法是现在连接例如设备端的抽象测量通道和具有共享代码的抽象类中的主机端的功能.这意味着,一旦我们为该通道创建设备或主机端的实际类,我们就必须隐藏另一方使用的功能.
这是可以接受的事情:
public abstract class ChannelAbstract
{
protected void ChannelAbstractMethodUsedByDeviceSide() { }
protected void ChannelAbstractMethodUsedByHostSide() { }
}
public abstract class MeasurementChannelAbstract : ChannelAbstract
{
protected void MeasurementChannelAbstractMethodUsedByDeviceSide() { }
protected void MeasurementChannelAbstractMethodUsedByHostSide() { }
}
public class DeviceMeasurementChannel : MeasurementChannelAbstract
{
public new void MeasurementChannelAbstractMethodUsedByDeviceSide()
{
base.MeasurementChannelAbstractMethodUsedByDeviceSide();
}
public new void ChannelAbstractMethodUsedByDeviceSide()
{
base.ChannelAbstractMethodUsedByDeviceSide();
}
}
public class HostMeasurementChannel : MeasurementChannelAbstract
{
public new void MeasurementChannelAbstractMethodUsedByHostSide()
{
base.MeasurementChannelAbstractMethodUsedByHostSide();
}
public new void ChannelAbstractMethodUsedByHostSide()
{ …Run Code Online (Sandbox Code Playgroud) 我在C#中编写了一个程序,以便在一定范围内找到完美的数字,作为编程挑战的一部分.但是,我意识到计算10000以上的完美数字时速度非常慢.有没有找到完美数字的优化方法?我的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleTest
{
class Program
{
public static List<int> FindDivisors(int inputNo)
{
List<int> Divisors = new List<int>();
for (int i = 1; i<inputNo; i++)
{
if (inputNo%i==0)
Divisors.Add(i);
}
return Divisors;
}
public static void Main(string[] args)
{
const int limit = 100000;
List<int> PerfectNumbers = new List<int>();
List<int> Divisors=new List<int>();
for (int i=1; i<limit; i++)
{
Divisors = FindDivisors(i);
if (i==Divisors.Sum())
PerfectNumbers.Add(i);
}
Console.Write("Output =");
for (int i=0; i<PerfectNumbers.Count; i++)
{
Console.Write(" …Run Code Online (Sandbox Code Playgroud) 根据"Jeff Heaton的Java神经网络简介",Kohonen神经网络的输入必须是介于-1和1之间的值.
可以对预先知道范围的输入进行标准化:例如RGB
(125,125,125),其中范围被称为0到255之间的值:
1.除以255:(125/255)= 0.5 >> (0.5,0.5,0.5)
2.乘以2并减1:((0.5*2)-1)= 0 >>(0,0,0)
问题是我们如何将范围未知的输入标准化,例如我们的身高或体重.
另外,其他一些论文提到输入必须归一化为0到1之间的值.这是正确的方法,"-1和1"或"0和1"?
假设我有两个类,A和B,其中B是A的子类.
我还有以下功能:
void foo(boost::shared_ptr<const A> a)
{
boost::shared_ptr<const B> b = boost::dynamic_pointer_cast<const B>(a); // Error !
}
Run Code Online (Sandbox Code Playgroud)
使用gcc编译给出了以下错误:
C:\Boost\include/boost/smart_ptr/shared_ptr.hpp: In constructor 'boost::shared_ptr< <template-parameter-1-1> >::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::dynamic_cast_tag) [with Y = const A, T = const B]':
C:\Boost\include/boost/smart_ptr/shared_ptr.hpp:522: instantiated from 'boost::shared_ptr<X> boost::dynamic_pointer_cast(const boost::shared_ptr<U>&) [with T = const B, U = const A]'
src\a.cpp:10: instantiated from here
C:\Boost\include/boost/smart_ptr/shared_ptr.hpp:259: error: cannot dynamic_cast 'r->boost::shared_ptr<const A>::px' (of type 'const class A* const') to type 'const class B*' (source type is not polymorphic)
Run Code Online (Sandbox Code Playgroud)
什么可能是错的?
谢谢.
实际上,我发现了如何避免这种情况,但我不确定. …
我的网站上有一个php文件,我连接到db,获取一些记录并将它们列在同一个文件中.
mysql_connect("localhost", "blabla", "blabla") or die(mysql_error());
mysql_select_db("blabla") or die(mysql_error());
$blabla1 = mysql_query("SELECT * FROM gallery WHERE id_cat=1");
$blabla2 = mysql_query("SELECT * FROM gallery WHERE id_cat=2");
$blabla3 = mysql_query("SELECT * FROM gallery WHERE id_cat=3");
Run Code Online (Sandbox Code Playgroud)
那么,我需要做些什么来保障安全吗?像sql-injection或其他任何东西.什么都没有.它只是www.blabla.com/gallery.php.