可能重复:
如何保护phpMyAdmin
我使用phpmyadmin来预览我的网站数据库.但是,每个人都可以通过输入来访问我的phpmyadmin的登录页面example.com/phpmyadmin
我不是网络安全方面的专家,但我认为这不是很安全.
如何限制对登录页面的访问(可能会创建一些别名example.com/a4ebb72d).我听说只允许访问指定的IP,但它没有帮助,因为我已动态分配IP.
我会感谢你的提示.
我有一个可以为空的int集合.
为什么编译器允许迭代变量的类型为int而不是int??
List<int?> nullableInts = new List<int?>{1,2,3,null};
List<int> normalInts = new List<int>();
//Runtime exception when encounter null value
//Why not compilation exception?
foreach (int i in nullableInts)
{
//do sth
}
Run Code Online (Sandbox Code Playgroud)
当然我应该注意我迭代的内容但如果编译器训斥我会很好:)就像这里:
foreach (bool i in collection)
{
// do sth
}
//Error 1 Cannot convert type 'int' to 'bool'
Run Code Online (Sandbox Code Playgroud) 我使用using语句SqlConnection.它对性能有好处,因为强制调用Dispose()会更快地释放与池的连接.
但是,我意识到在使用中创建的对象无法重新定义.我不能这样做:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
//...
connection = new SqlConnection(connectionString2);
//...
connection = new SqlConnection(connectionString3);
}
Run Code Online (Sandbox Code Playgroud)
我想知道我是否可以替换使用,并做这样的事情:
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
//...
connection = new SqlConnection(connectionString2);
//...
connection = new SqlConnection(connectionString3);
}
Run Code Online (Sandbox Code Playgroud)
该SqlConnection不会是最后一次入店后}梅开二度.当对象超出范围时,Dispose()会立即被调用吗?
我在VB中有以下方法声明,需要将其转换为C#:
<DllImport("winspool.Drv", EntryPoint:="OpenPrinterW", _
SetLastError:=True, CharSet:=CharSet.Unicode, _
ExactSpelling:=True, CallingConvention:=CallingConvention.StdCall)> _
Public Shared Function OpenPrinter(ByVal src As String, ByRef hPrinter As IntPtr, ByVal pd As Int16) As Boolean
End Function
Run Code Online (Sandbox Code Playgroud)
特别是我不确定ByRef参数说明符是否等同于refC#.
我也不知道Shared == static是否必须如此extern.可能很多人都精通VB和C#,所以我很感激在C#中提供正确的声明.
我想在两个线程之间实现以下通信:
线程Alpha执行某些操作,然后暂停.接下来第二个线程(Beta)引发并恢复Alpha线程的事件.这个循环继续......
我做了类似下面的事情,但我不确定它是否是一个合适的设计.我也注意到Thread.Suspend()并且Thread.Resume()已被弃用.我期待听到有关此实现的任何建议以及更换弃用方法的首选方法.
namespace ThreadTester
{
delegate void ActionHandler();
class Alpha
{
internal Thread alphaThread;
internal void Start()
{
while (true)
{
this.alphaThread.Suspend();
Console.WriteLine("Alpha");
}
}
internal void Resume()
{
while (this.alphaThread.ThreadState == ThreadState.Suspended)
this.alphaThread.Resume();
}
}
class Beta
{
internal event ActionHandler OnEvent;
internal void Start()
{
for (int i = 0; i < 15; i++)
{
OnEvent();
Thread.Sleep(1000);
}
}
}
class Program
{
static void Main(string[] args)
{
Alpha alpha = new Alpha(); …Run Code Online (Sandbox Code Playgroud) 我想使用反射来显示接口中的方法列表.
public interface IRoadVehicle
{
int WheelCount { get; }
bool IsEmergency();
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码:
foreach (var m in typeof(IRoadVehicle).GetMethods())
{
Console.WriteLine(m.Name);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果接口具有属性,我还会列出编译器生成的属性访问器.我想区分显式定义的方法和属性访问器以省略后者.
//output:
//get_WheelCount
//IsEmergency
//desired output:
//IsEmergency
Run Code Online (Sandbox Code Playgroud)
如何过滤掉与属性相关的方法?
作为一个非英语的人,我经常会遇到某些编程结构和缩写的问题.我一直在观看一些视频教程和收听播客,虽然我无法抓住它们.
我的问题是以下代码片段的常见或正确发音是什么?
泛型,像
IEnumerable<int> 或者在一种方法中 void Swap<T>(T lhs, T rhs)
集合索引和索引器访问例如
garage[i],矩形阵列myArray[2,1]或jagged[1][2][3]
Lambda运算符=>,例如在where扩展方法中
.Where(animal => animal.Color == Color.Brown)
或者以匿名方式
() => { return false;}
遗产
class Derived : Base (延伸?)
class SomeClass : IDisposable (实现?)
Arithemtic运营商
+= -= *= /= %= !
是+=和-=发音相同的事件?
集合初始化器
new int[] { 4, 5, 8, 9, 12, 13, 16, 17 };
铸件
MyEnum foo = (MyEnum)(int)yourFloat; (如?)
Nullables
DateTime? dt = new DateTime?(); …
当我退出我的C++程序时,它会崩溃,例如:
EAccessViolation with mesage 'Access violation at address 0...
and
Abnormal Program Termination
Run Code Online (Sandbox Code Playgroud)
它可能是由一些析构函数引起的,因为它只在应用程序退出时才会发生.我使用了一些外部库,但找不到导致它的代码.是否有一个强制立即退出程序的函数(类似Linux中的kill),以便操作系统必须释放内存?我可以在app退出事件中使用此功能.
我知道这将是一个可怕的解决方案,因为它只是隐藏问题.
我只是出于纯粹的好奇心,所以请不要给我-1 :)
我尝试exit(0)从stdlib但它没有帮助.
编辑:
感谢您的众多回复:)我使用Builder C++ 6(我知道它已经过时但由于某些原因我不得不使用它).我的应用程序使用库到神经网络(FANN).使用调试器我发现程序崩溃:
~neural_net()
{
destroy();
}
Run Code Online (Sandbox Code Playgroud)
destroy()多次调用另一个函数fann_safe_free(ptr),即:
#define fann_safe_free(x) {if(x) { free(x); x = NULL; }}
Run Code Online (Sandbox Code Playgroud)
该库工作得很好,只有在清理时才会出现问题.这就是为什么我问这么残酷的解决方案.我的应用程序是多线程的,但其他线程对不同的数据进行操作.
我将在第n次分析我的代码(错误必须在某处),感谢您的所有提示:)
我是WPF的初学者.我想将以下DataSet包含节点和关系绑定到a TreeView.数据集是:
internal static DataSet getData()
{
DataTable dt = new DataTable("data");
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("ParentId", typeof(int));
dt.Columns.Add("NodeDescription");
dt.Rows.Add(1, null, "Employees");
dt.Rows.Add(2, null, "Cars");
dt.Rows.Add(3, 1, "Men");
dt.Rows.Add(4, 1, "Women");
dt.Rows.Add(5, 2, "BMW");
dt.Rows.Add(6, 2, "Lexus");
dt.Rows.Add(7, 3, "Adam Kowalski");
dt.Rows.Add(8, 3, "Dawid Nowacki");
dt.Rows.Add(9, 4, "Ilona Wacek");
DataSet ds = new DataSet();
ds.Tables.Add(dt);
//add a relationship
ds.Relations.Add("rsParentChild"
,ds.Tables["data"].Columns["Id"]
,ds.Tables["data"].Columns["ParentId"]);
return ds;
}
Run Code Online (Sandbox Code Playgroud)
我想拥有:

现在我通过将所有数据表和ading节点恢复到树视图来实现这一点.但是,我希望有直接XAML约束力.
我想补充一点,数据集将动态变化,并且可能存在许多嵌套级别.谢谢.
我想为复杂类型定义自己的别名.我很好奇为什么编译器不能识别已导入的类型.例如:
作品:
using System;
using System.Collections.Generic;
using myCollection = System.Collections.Generic.List
<System.Collections.Generic.Dictionary<string, string>>;
Run Code Online (Sandbox Code Playgroud)
错误:
using System;
using System.Collections.Generic;
using myCollection = List<Dictionary<string, string>>;
Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×2
c++ ×1
dataset ×1
events ×1
foreach ×1
interface ×1
nullable ×1
php ×1
phpmyadmin ×1
properties ×1
reflection ×1
scope ×1
security ×1
translation ×1
treeview ×1
using ×1
vb.net ×1
wpf ×1