小编Cra*_*yWu的帖子

Laravel雄辩的域名规则

域名有什么具体规则吗?谷歌搜索大约一个小时,但没有获得规则列表.我已经尝试了,"domain" => "required|url"但它正在要求它中的协议类型,所以它不是我的最佳选择.

php laravel eloquent

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

HashSet 的自定义比较

我正在尝试为我的班级创建一个自定义比较器:

using System.Collections.Generic;

namespace i.changed.namespaces.DataStructures
{
public class Edge
{
    public Cords startPoint, endPont;
    public double length;

    //more code here that doesnt matter
}

public class EdgeComparer : IEqualityComparer<Edge>
{
    public bool Equals(Edge x, Edge y)
    {
        //Check whether the objects are the same object. 
        if (x.Equals(y)) return true;

        return x.startPoint.Equals(y.startPoint) && x.endPont.Equals(y.endPont) && (x.length - y.length < 0.0001);

    }

    public int GetHashCode(Edge obj)
    {
        int hash = 17;
        hash = hash * 23 + obj.length.GetHashCode();
        hash = hash * …
Run Code Online (Sandbox Code Playgroud)

c# union hashset

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

如何释放记忆?

我开始学习Go,发现了一些我无法找到的信息.

例如,如果我正在创建自己的列表结构

type elem struct {
    prev  *elem
    next  *elem
    value string
}
Run Code Online (Sandbox Code Playgroud)

并添加新的元素

Current.next = &elem{}
Run Code Online (Sandbox Code Playgroud)

我应该如何删除它们?我的意思是,如何从内存中删除elem的数据,而不仅仅是从列表中删除?

garbage-collection memory-management go

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

c#是否可以更改父类的字段类型?

如果我有2个类,一个用于数据,例如:

public class Cords
{
    public double x;
    public double y;
}
Run Code Online (Sandbox Code Playgroud)

一,使用这些数据:

public class Geometry
{
    public Cords()
    {
        points = new List<Cords>();
    }
    public void SomeMathWithPoints()
    {
         MagicWithPoints(points);
    }

    protected List<Cords> points;
}
Run Code Online (Sandbox Code Playgroud)

我想用一些特定的函数,使用继承来扩展这个类,但这次我需要一些Cords类的附加数据.所以我试着这样做:

public class ExtendedCords: Cords
{
    public double x;
    public double y;
    public string name;
}

public class ExtendedGeometry : Geometry
{
     protected SomeNewMagicWithPoints(){...}
     protected List<ExtendedCords> points;
}
Run Code Online (Sandbox Code Playgroud)

但我注意到,如果我愿意:

    ExtendedGeometry myObject = new ExtendedGeometry();
    myObject.SomeMathWithPoints();
Run Code Online (Sandbox Code Playgroud)

此函数将使用旧(parrents)字段points.那么如何让它使用一个类型的新ExtendedCords?我的意思是,我希望能够在新领域使用child和parrent的功能.

c# oop inheritance field

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