它总是令人困惑,并且没有提到哪个更好,我个人更喜欢 JsonWebTokenHandler,因为它是 ValidateToken 的更合适的返回类型
命名空间的区别是 Microsoft.IdentityModel.JsonWebTokens 与 System.IdentityModel.Tokens.Jwt,这也很相似?
有可用的指南吗?
我有一个名为Shape的基类和一个派生类Rectangle,它派生自Shape.
class Shape
{
public virtual void Draw()
{
//Draw the Shape
Console.WriteLine("Draw the Shape");
}
}
class Rectangle : Shape
{
public override void Draw()
{
Console.WriteLine("Draw Rectangle");
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个非常基本的疑问,当我调用派生类的方法时,我会做这样的事情.
Shape r1 = new Rectangle();
r1.Draw();
Run Code Online (Sandbox Code Playgroud)
但是如果我想调用Rectangle类的方法,我总是可以这样做.
Rectangle r2 = new Rectangle();
r2.Draw();
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我们总能使用易于理解和实现的第二种方法时,为什么我们需要使用第一种方法.
.net ×1
.net-core ×1
asp.net-core ×1
c# ×1
inheritance ×1
jwt ×1
overriding ×1
polymorphism ×1