Salesforce Generic Sharing Record Using sObject

Sample Code:

//Create sharing object for the custom object Student
Schema.SObjectType stdShareType = Schema.getGlobalDescribe().get('Student__Share');
SObject stdShare = stdShareType.newSObject();
stdShare.put('ParentId', 'a0E0I00000fFSUBUA4'); //Set the ID of record being shared
stdShare.put('UserOrGroupId', UserInfo.getUserId()); //Set the ID of User or Group or Territory being granted access
stdShare.put('AccessLevel', 'Read'); //Set the Account access level
stdShare.put('RowCause', 'Student__c'); //Set the Row Cause reason
Database.SaveResult sr = Database.Insert(stdShare,false);